Advertisement
Guest User

passphrase creation script

a guest
Oct 29th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import re
  4. import sys
  5. import random
  6.  
  7. wordre = re.compile("\w+")
  8. filename = sys.argv[-1]
  9.  
  10. wordset = set()
  11.  
  12. f = open(filename)
  13.  
  14. try:
  15.     for line in f:
  16.         words = wordre.findall(line)
  17.         for word in words:
  18.             wordset.add(word.lower())
  19. finally:
  20.     f.close()
  21.  
  22. wordlist = list(wordset)
  23.  
  24. passphrase = [random.choice(wordlist) for x in range(7)]
  25.  
  26. print(filename)
  27.  
  28. print("{:n} unique words".format(len(wordlist)))
  29.  
  30. print(" ".join(passphrase))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement