Created
June 7, 2019 17:10
-
-
Save clementi/92aeed413028c92dd3480b5cc08c1623 to your computer and use it in GitHub Desktop.
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 secrets | |
import string | |
import sys | |
def generate_password(chars, size): | |
return ''.join(secrets.choice(chars) for _ in range(size)) | |
def main(): | |
size = 20 if len(sys.argv) < 2 else int(sys.argv[1]) | |
chars = string.ascii_letters + string.digits + string.punctuation | |
print(generate_password(chars, size)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment