Advertisement
opexxx

dicewarepw.py

Mar 31st, 2015
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. def generate_diceware_password(word_count=6):
  2.     import random
  3.     word_dict = {}
  4.     passphrase = []
  5.     with open('diceware.wordlist.andy.txt') as f:
  6.         for line in f.readlines():
  7.             index, word = line.strip().split('\t')
  8.             word_dict[int(index)] = word
  9.     for words in range(0, word_count):
  10.         this_index = 0
  11.         for position in range(0, 5):
  12.             digit = random.randint(1, 6)
  13.             this_index += digit * pow(10, position)
  14.         passphrase.append(word_dict[this_index])
  15.     return ' '.join(passphrase)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement