import random
import string
print("---Welcome to Random Password Generator Tool---")
characters = string.ascii_letters + string.digits + string.punctuation
lengthOfPass = int(input("Enter the length of your required password (max length allowed is 94): "))
temp_password = random.sample(characters, lengthOfPass)
password = "".join(temp_password)
print("Your password is", password)
# or the following code can be used, both do the same job
import random
import string
upper_chars = string.ascii_uppercase
lower_chars = string.ascii_lowercase
nums_chars = string.digits
symbol_chars = string.punctuation
all_chars = upper_chars + lower_chars + nums_chars + symbol_chars
length_pass = int(input("Enter the required password length(Max=94): "))
temp_password = random.sample(all_chars, length_pass)
password = "".join(temp_password)
print(password)
Comments
Post a Comment
Write something to CodeWithAbdur!