Skip to content

Instantly share code, notes, and snippets.

@kmansoft
Created September 13, 2020 14:14
Show Gist options
  • Save kmansoft/e1e756cc44d4877eb67bae328e7e7872 to your computer and use it in GitHub Desktop.
Save kmansoft/e1e756cc44d4877eb67bae328e7e7872 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import argparse
import secrets
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-'
if __name__ == "__main__":
'''
Parse command line arguments
'''
parser = argparse.ArgumentParser(description='Generates random passwords')
parser.add_argument('-l', dest='LEN', type=int, default=20, help='password length')
parser.add_argument('-n', dest='COUNT', type=int, default=10, help='password count')
args = parser.parse_args()
for p in range(0, args.COUNT):
pwd = ''
for i in range(0, args.LEN):
pwd += secrets.choice(ALPHABET)
print(u'Password: {0}'.format(pwd))
print(u'Generated {0} passwords, {1} characters each'.format(args.COUNT, args.LEN))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment