Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def get_char():
  5. return random.choice(characters)
  6.  
  7.  
  8. def print_password(password):
  9. print("auto-generated password is:")
  10. print(password)
  11.  
  12.  
  13. def set_password(strength):
  14. password = ""
  15. if strength == "1":
  16. for i in range(6):
  17. password += get_char()
  18. return password
  19. elif strength == "2":
  20. for i in range(10):
  21. password += get_char()
  22. return password
  23. elif strength == "3":
  24. for i in range(14):
  25. password += get_char()
  26. return password
  27. elif strength == "4":
  28. for i in range(20):
  29. password += get_char()
  30. return password
  31.  
  32.  
  33. characters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', '@', '#', '$', '%', '&', '*', '(', ')']
  34.  
  35. strength = input("Enter strength: 1 for weak - 2 for medium - 3 for strong - 4 for extra strong: ")
  36.  
  37. password = set_password(strength)
  38.  
  39. print_password(password)
  40.  
  41. print("now i will try to break your password")
  42.  
  43. n = len(characters)
  44. m = len(password)
  45. found = ""
  46. j=0
  47. i=0
  48. while i < n:
  49. deneme = characters[i]
  50. while j < m:
  51. if deneme == password[j]:
  52. found += deneme
  53. j += 1
  54. i = 0
  55. print(found)
  56. break
  57. else:
  58. i += 1
  59. break
  60. if found == password:
  61. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement