Last active
February 23, 2020 10:59
-
-
Save shaunmolloy/29331c40fa9b729cba350125c022f754 to your computer and use it in GitHub Desktop.
pass - Generate password, with custom length
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 python | |
# pass | |
# Generate password, with custom length | |
import sys | |
import secrets | |
import string | |
if not len(sys.argv) > 1: | |
length = 16 | |
else: | |
length = int(sys.argv[1]) | |
alphabet = string.ascii_letters + string.digits | |
password = ''.join(secrets.choice(alphabet) for i in range(length)) | |
print(password) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment