Skip to content

Instantly share code, notes, and snippets.

@shaunmolloy
Last active February 23, 2020 10:59
Show Gist options
  • Save shaunmolloy/29331c40fa9b729cba350125c022f754 to your computer and use it in GitHub Desktop.
Save shaunmolloy/29331c40fa9b729cba350125c022f754 to your computer and use it in GitHub Desktop.
pass - Generate password, with custom length
#!/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