mardi 29 décembre 2020

Generating password using Python

I have written a Python program to generate password. There is a glitch because it is not properly shuffled. Please suggest some methods to do it. Also suggest better methods for the same.

import random 
import array

digits = ['0','1','2','3','4','5','6','7','8','9']
lowercase = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
uppercase = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
Symbols = ['!','@','#','$','%','*','&']

mixture = digits + lowercase + uppercase + Symbols

random_digit = random.choice(digits)
random_lowercase = random.choice(lowercase)
random_uppercase = random.choice(uppercase)
random_symbol = random.choice(Symbols) 

Password = random_digit + random_lowercase + random_uppercase + random_symbol

length = random.randint(8,12)

for x in range (length) :
    Password = Password + random.choice(mixture) 

print(Password)



Aucun commentaire:

Enregistrer un commentaire