ejherran

Generador De Claves Tipo Rueda

May 8th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import time
  4.  
  5. def wheelCombine(wheels, elements):
  6.    
  7.     idx = [0] * wheels
  8.     lim = len(elements)
  9.     com = open('wcom.txt', 'w')
  10.     tmp = ''
  11.     cnt = 0
  12.    
  13.     while(True):
  14.        
  15.         for i in idx:
  16.             tmp += elements[i]
  17.         tmp = tmp+"\n"
  18.         cnt += 1
  19.        
  20.         if (cnt % 65536) == 0:
  21.             com.write(tmp)
  22.             tmp = ''
  23.             print("Writing block!. "+str(cnt))
  24.        
  25.         idx[wheels - 1] += 1
  26.        
  27.         for i in range(wheels - 2, -1, -1):
  28.            
  29.             if idx[i+1] == lim:
  30.                 idx[i+1] = 0
  31.                 idx[i] += 1
  32.        
  33.         if idx[0] == lim:
  34.             break
  35.    
  36.     com.write(tmp)
  37.     com.close()
  38.    
  39.     return cnt
  40.  
  41. te = time.time()
  42. cnt = wheelCombine(8, ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'])
  43. te = time.time()-te
  44. print(str(cnt) + " Keys generated. Time elapsed: " + str(te) +" sec.")
Advertisement
Add Comment
Please, Sign In to add comment