Skip to content

Instantly share code, notes, and snippets.

@wmelvin
Created March 29, 2022 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmelvin/2f2ae053f33407a95ab2e744b6664a16 to your computer and use it in GitHub Desktop.
Save wmelvin/2f2ae053f33407a95ab2e744b6664a16 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# https://docs.python.org/3/library/secrets.html
import secrets
s = secrets.token_urlsafe(15)
n1 = secrets.randbelow(len(s))
n2 = secrets.randbelow(len(s))
a = '~!@#$%^&*()-_+=:;'
a1 = secrets.choice(a)
a2 = secrets.choice(a)
t = s[:n1] + a1 + s[n1:]
t = t[:n2] + a2 + t[n2:]
print(t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment