Skip to content

Instantly share code, notes, and snippets.

@redraw
Last active October 23, 2018 19:51
Show Gist options
  • Select an option

  • Save redraw/4faa5d6dc80f96ce23c6d6fc42adae0c to your computer and use it in GitHub Desktop.

Select an option

Save redraw/4faa5d6dc80f96ce23c6d6fc42adae0c to your computer and use it in GitHub Desktop.
#!/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