Skip to content

Instantly share code, notes, and snippets.

@clementi
Created June 7, 2019 17:10
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 clementi/92aeed413028c92dd3480b5cc08c1623 to your computer and use it in GitHub Desktop.
Save clementi/92aeed413028c92dd3480b5cc08c1623 to your computer and use it in GitHub Desktop.
#!/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