Skip to content

Instantly share code, notes, and snippets.

@myyc
Last active April 9, 2019 15:52
Show Gist options
  • Save myyc/8c814e59be4115c929a2a2173126c388 to your computer and use it in GitHub Desktop.
Save myyc/8c814e59be4115c929a2a2173126c388 to your computer and use it in GitHub Desktop.
a password generator
#!/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