Guest User

Random password from word list

a guest
Mar 24th, 2020
66
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import argparse
  2. import numpy as np
  3.  
  4. parser = argparse.ArgumentParser(description='Generate random xkcd-style password.')
  5. parser.add_argument('-n', '--num-words', type=int, default=4,
  6.                     help='Number of words in the password. Default: 4')
  7. args = parser.parse_args()
  8.  
  9. # Read words from file
  10. with open("word_list.txt", 'r', encoding='UTF-8') as f:
  11.     word_list = f.read()
  12. words = word_list.splitlines()[1:]
  13.  
  14. # Randomly choose words
  15. rnd_words = np.random.choice(words, size=args.num_words)
  16. print(' '.join(rnd_words))
RAW Paste Data