mercredi 5 juin 2019

Password Generator on Python 3 using string and random modules

so I have a question.

I've made a password generator, and I need it to generate 1 uppercase letter and 1 symbol and then connect random booleans to them, so it can be either 1 or 0 uppercase letters/symbols.

Code:

import random, os, string # Imports

while 1: # Infinite cycle!
    chars = string.ascii_lowercase + string.digits # Combining all lowercase letters and all digits
    random.seed(os.urandom(1024)) # RaNdOmNeSs!!1

    password_length = 7 # Password length, you can change it
    password = ''.join(random.choice(chars) for length in range(password_length)) # Password generation

    print(password) # Printing
    input('>> ') # Waiting for user to input, so the program can generate a new password
    os.system('clear') # Clearing screen




Aucun commentaire:

Enregistrer un commentaire