Skip to main content
Solved

Random Password Generator: password always starts with letter

  • March 4, 2021
  • 1 reply
  • 42 views

fikusas
Contributor
Forum|alt.badge.img+5

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)

 

Best answer by david_r

Suggestion:

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

 

View original
Did this help you find an answer to your question?

1 reply

david_r
Celebrity
  • Best Answer
  • March 4, 2021

Suggestion:

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

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings