import secrets import string def generate_password(length): # A character set that includes letters, numbers, and special characters chars = string.ascii_letters + string.digits + string.punctuation # Generate a random password of the specified length password = ''.join(secrets.choice(chars) for i in range(length)) return password # Generate a password of length 16 print(generate_password(16)) Thank you to @xavdid@mastodon.social for letting us know that the original code wasn't quite secure as originally posted using random instead of secrets.
Comments are closed.
|
About UsThe Missouri and Kansas Cyber Alliance Network promotes free expression, security, privacy, creativity, and access to knowledge in the Sunflower and Show Me states. |