learner
0
Q:

random password python

import secrets 
secrets.token_hex(nbytes=16)

# this will produce something like 
# aa82d48e5bff564f3221d02194611c13
1
import random

alph = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ\
             abcdefghijklmnopqrstuvwxyz\
             1234567890 !@#$%^&*(){}[]<>,.')
out = ''
for char in string:
    out += random.choice(alph)
    
print(out)
1
password_length = 5
possible_characters = "abcdefghijklmnopqrstuvwxyz1234567890"

random_character_list = [random.choice(possible_characters) for i in range(password_length)]
random_password = "".join(random_character_list)
print(random_password)
0

New to Communities?

Join the community