mercredi 29 avril 2020

password generation python with condition

I have the below password generator script based on characters, numbers and some special chars which are ultimately generating the combination of password based on length provided. This script works as intended.

Code outlined below:

$ cat passwd_gen.py
#!/usr/local/bin/python3.6
import random

def pass_Gen(length):
    passwd = str()
    chars = "!@#$%~" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789"
    for pas in range(length):
        passwd = passwd + random.choice(chars)
    print(passwd)

if __name__ == "__main__":
    pass_Gen(10)

Resulted Output:

$ ./passwd_gen.py
@1wUErxil#

Desired Outcome:

I am looking forward the Initial Character of password should be Starting with uppercase Char and Special Char rest all is good.

@E1UErxil#



Aucun commentaire:

Enregistrer un commentaire