#!/usr/bin/env python2.7

from random import randint
import sys
# imports separate dictionary file
import dice_dict as d
#####################################################################
# TODO:                                                             #
#   Use better RNG                                                  #
#   Incorporate argparse                                            #
#   Create options for copying to clipboard                         #
#   Create options for different output formats of password, i.e.:  #
#                                      special chars                #
#                                      replace numbers with letters #
#   Maybe incorporate different word-list                           #
#####################################################################

def usage():
    sys.stdout.write('Usage:\n\t'+sys.argv[0]+' [#]\n')
    sys.stdout.write('\t#\tNumber of words to generate in password')

# creates a random where each digit is between 1 and 6 joins into one number
def rand_Key():
    key = [randint(1,6) for p in range(0,5)]
    keyInt = ''.join(map(str,key))
    return int(keyInt)

# matches and yields generated words
def word_return(n_of_Words):
    try:
        count = 1
        while count <= n_of_Words:
            count += 1
            key = rand_Key()
            word = d.dice[key]
            yield word
    except KeyboardInterrupt:
        sys.exit()

# Just get argv[1] and run the functions above
def main():
    sys.stdout.write('http://world.std.com/~reinhold/diceware.html\n\n')
    try:
        n_of_Words = int(sys.argv[1])
        words = word_return(n_of_Words)
        for word in words:
            sys.stdout.write(word.title())
    except ValueError:
        usage()
        sys.exit()
    except IndexError:
        usage()
        sys.exit()

if __name__ == '__main__':
    main()
@@ -23,103 +23,8 @@
 .7%0A%0A
-from random import randint%0Aimport sys%0A# imports separate dictionary file%0Aimport dice_dict as d%0A
 ####
@@ -163,148 +163,8 @@
   #%0A
-#   Use better RNG                                                  #%0A#   Incorporate argparse                                            #%0A
 #   
@@ -416,20 +416,20 @@
 replace 
-numb
+lett
 ers with
@@ -429,20 +429,20 @@
 rs with 
-lett
+numb
 ers #%0A# 
@@ -580,16 +580,160 @@
 ######%0A%0A
+from random import SystemRandom%0Afrom pyperclip import copy%0Aimport sys%0Aimport argparse%0A# imports separate dictionary file%0Aimport dice_dict as d%0A%0A
 def usag
@@ -964,22 +964,57 @@
     
-key = %5Brandint
+crypt = SystemRandom()%0A    key = %5Bcrypt.randrange
 (1,6
@@ -1161,29 +1161,16 @@
 Words):%0A
-    try:%0A    
     coun
@@ -1171,28 +1171,24 @@
   count = 1%0A
-    
     while co
@@ -1214,20 +1214,16 @@
         
- 
-   
 count +=
@@ -1225,20 +1225,16 @@
 nt += 1%0A
-    
         
@@ -1254,28 +1254,24 @@
 y()%0A        
-  
-  
 word = d.dic
@@ -1285,20 +1285,16 @@
         
-    
 yield wo
@@ -1300,241 +1300,401 @@
 ord%0A
-    except KeyboardInterrupt:%0A        sys.exit()%0A%0A# Just get argv%5B1%5D and run the functions above%0Adef main():%0A    sys.stdout.write('http://world.std.com/~reinhold/diceware.html%5Cn%5Cn')%0A    try:%0A        n_of_Words = int(sys.argv%5B1%5D)%0A    
+%0A# Handle arguments and options%0Adef main():%0A    opt = argparse.ArgumentParser(%0A        description='Create A password from a virtual diceroll',%0A        usage='%25(prog)s %5B-h%5D %5B-w --words%5D')%0A%0A    opt.add_argument(%0A        '-w','--words',%0A        type=int,%0A        help='Number of words to create',%0A        metavar='',%0A        required=True)%0A%0A    arg = opt.parse_args()%0A    n_of_Words = arg.words%0A
     
@@ -1725,20 +1725,17 @@
 _Words)%0A
-    
+%0A
     for 
@@ -1745,28 +1745,24 @@
 d in words:%0A
-    
         sys.
@@ -1791,124 +1791,8 @@
 e())
-%0A    except ValueError:%0A        usage()%0A        sys.exit()%0A    except IndexError:%0A        usage()%0A        sys.exit()
 %0A%0Aif

Add argparse, use better rng