Skip to content

Instantly share code, notes, and snippets.

@vadviktor
Created March 25, 2022 19:55
Show Gist options
  • Save vadviktor/1d3dbe40d47bab9330364ffdd452f8cb to your computer and use it in GitHub Desktop.
Save vadviktor/1d3dbe40d47bab9330364ffdd452f8cb to your computer and use it in GitHub Desktop.
Python random password generator
# https://stackoverflow.com/questions/3854692/generate-password-in-python
import string
import secrets
length = 42
password = ""
for _ in range(length):
l = secrets.choice(string.ascii_lowercase)
u = secrets.choice(string.ascii_uppercase)
d = secrets.choice(string.digits)
s = secrets.choice(string.punctuation)
password += secrets.choice(l + u + d + s)
print(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment