Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1.  
  2. def gen_passwd_list(passwd_len, charset = "012", limit = 0):
  3. ret = []
  4. if (type(charset) != 'list'):
  5. charset_ = charset
  6. charset = []
  7. for x in charset_:
  8. charset.append(x)
  9.  
  10. passwd = []
  11. for i in range(passwd_len):
  12. passwd.append(0)
  13.  
  14. # comb_count = pow(len(charset), len(passwd))
  15.  
  16. def _passwd(passwd):
  17. ret = ""
  18. for x in passwd:
  19. ret+=charset[x]
  20. return ret
  21.  
  22. charset_len = len(charset)
  23. last = passwd_len-1
  24. while 1:
  25. ret.append(_passwd(passwd))
  26. if (limit):
  27. if (len(ret) == limit):
  28. break
  29. passwd[last] += 1
  30. if (passwd[last] == charset_len):
  31. passwd[last] = 0
  32.  
  33. pos = last-1
  34. while pos >= 0:
  35. passwd[pos] += 1
  36. if (passwd[pos] == charset_len):
  37. passwd[pos] = 0
  38. pos -= 1
  39. continue
  40. break
  41.  
  42. if pos < 0:
  43. break
  44. return ret
  45.  
  46.  
  47. charset = "0123456789"
  48.  
  49. pp = gen_passwd_list(4,charset)
  50. for p in pp:
  51. print p
Add Comment
Please, Sign In to add comment