Password Generator|Python
Here’s a simple python code to generate random passwords which are a shuffle of uppercase and lowercase letters, numbers and special characters. it output string of characters of a random length between six and twelve characters long. there’s very little chance that the generator will create the same result twice because being random meaning the results will be unpredictable.I tried to write this code to be very clear and simple. once the user run the following code it displays a unique password.
The Python code
import random
import stringdef GeneratePassword():
password = random.choice(string.ascii_lowercase)
password += random.choice(string.ascii_uppercase)
password += random.choice(string.digits)
password += random.choice(string.punctuation)
password += string.ascii_letters + string.digits + string.punctuationsize = random.randint(6, 12)
return ‘’.join(random.choice(password) for i in range(size))
print(“The password is : “,GeneratePassword())
Pseudo code
Assume that uppercase randomly generate uppercase letters between A and Z
Assume that lowercase randomly generate lowercase letters between a and z
Assume that digits randomly generate digits between 0 and 9
Assume that punctuation sign randomly generate punctuation sign
password=uppercase + lowercase + digit + punctuation sign
password length should be in range 6:12
Output ’the password is ’,password