random password python code example
Example 1: password generator python
import string
from random import *
characters = string.ascii_letters + string.punctuation + string.digits
password = "".join(choice(characters) for x in range(randint(8, 16)))
print password
Example 2: python random string
import secrets
secrets.token_hex(nbytes=16)
Example 3: python random password generator
import random
alph = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz\
1234567890 !@
out = ''
for char in string:
out += random.choice(alph)
print(out)
Example 4: password generator python
import random
i=0
list=[]
while i < 12:
while i < 8:
list.append(random.choice(string.ascii_letters))
i+=1
while i < 12:
list.append(random.randint(0, 9))
i+=1
list=' '.join([str(elem) for elem in list])
print("Your new password: ", list.replace(" ", ""))