Last active
August 29, 2015 13:56
-
-
Save johngian/9005563 to your computer and use it in GitHub Desktop.
Password generator from regular expression.
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
# Dependencies: pip install exrex | |
# Run: python ./regexpassgen.py --output <filename> <regex> | |
import argparse | |
import exrex | |
if __name__=='__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('regex', type=str, help='Password generator regex.') | |
parser.add_argument('-o', '--output', action='store', help='Output file.') | |
args = parser.parse_args() | |
passwords = exrex.generate(args.regex) | |
try: | |
f = open(args.output, 'w') | |
try: | |
for p in passwords: | |
f.write(p) | |
f.write('\n') | |
finally: | |
f.close() | |
except IOError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment