Last active
April 9, 2019 15:52
-
-
Save myyc/8c814e59be4115c929a2a2173126c388 to your computer and use it in GitHub Desktop.
a password generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
def genpasswd() -> str: | |
nc = random.randint(36, 48) | |
rc = [] | |
for l in ([chr(65+i) for i in range(26)], # uppercase | |
[chr(97+i) for i in range(26)], # lowercase | |
list(str(i) for i in range(10)), ["/", "+"]): | |
rc = rc + l | |
s = "" | |
for i in range(nc): | |
s += rc[random.randint(0, len(rc)-1)] | |
try: | |
import pasteboard | |
pb = pasteboard.Pasteboard() | |
pb.set_contents(s) | |
except ImportError: | |
pass | |
return s | |
genpasswd() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment