password generator module 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: how to create a password generator in python
import random
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789!@€$#%({)}],/<\.>[*^&"
while 1:
password_len = int(input("What length would you like your password to be ? :"))
password_count = int(input("How many passwords would you like ? "))
for x in range(0, password_count):
password = ""
for x in range(0,password_len):
password_char = random.choice(chars)
password = password + password_char
print("Here is your password : ",password)
Example 3: 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(" ", ""))