Last active
October 23, 2018 19:51
-
-
Save redraw/4faa5d6dc80f96ce23c6d6fc42adae0c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 random | |
| import string | |
| import argparse | |
| def generate_password(n, no_punctuation=False): | |
| wordspace = string.ascii_letters | |
| if not no_punctuation: | |
| wordspace += string.punctuation | |
| return "".join([random.choice(wordspace) for _ in range(n)]) | |
| def main(args): | |
| print(generate_password(args.n, no_punctuation=args.no_punctuation)) | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('-np', '--no-punctuation', help='No punctuation', action='store_true', default=False) | |
| parser.add_argument('-n', help='Length', type=int, default=32) | |
| args = parser.parse_args() | |
| main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment