Solved

Random Password Generator: password always starts with letter

  • 4 March 2021
  • 1 reply
  • 7 views

Badge

How can I force that first symbol of generated passwords always be letter? I'm using this:

import fmeobjects
import random
import string
 
def processFeature(feature):
    length = int(FME_MacroValues['Lenght'])
    
    letters = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
    digits = '123456789'
    symbols = '!#$%*+-:;<=>?'
    all = letters + digits + symbols
    temp = random.sample(all,length)
    
    password = "".join(temp)
    feature.setAttribute('Password', password)

 

icon

Best answer by david_r 4 March 2021, 15:01

View original

1 reply

Userlevel 4

Suggestion:

temp = random.sample(letters, 1) + random.sample(all, length-1)

 

Reply