Advertisement
Guest User

Untitled

a guest
Mar 11th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. import random
  2. from password_strength import PasswordPolicy
  3. from password_strength import PasswordStats
  4.  
  5. #policy
  6. policy = PasswordPolicy.from_names(
  7. length=8, # min length: 8
  8. uppercase=2, # need min. 2 uppercase letters
  9. numbers=2, # need min. 2 digits
  10. special=2, # need min. 2 special characters
  11. nonletters=2,) # need min. 2 non-letter characters (digits, specials, anything)
  12.  
  13. #Variables
  14. password = ""
  15. combinations="qwertyuiopasdfghjklzxcxvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM!$%^&*"
  16.  
  17. #funkcijos
  18. def generuoti():
  19. global password
  20. global combinations
  21. i = input("Kokio ilgio slaptazodzio jus norite: ")
  22.  
  23. #generuoja skaicius
  24. try:
  25. for x in range(int(i)):
  26. password += random.choice(combinations)
  27. except:
  28. print("Klaida!")
  29. print(password)
  30.  
  31. #test
  32. stats = PasswordStats(password)
  33. saugumas = stats.strength()
  34. policy_saugumas = policy.test(password)
  35.  
  36. if policy_saugumas != []:
  37. print("Slaptazodziui truksta: " + str(policy_saugumas))
  38. elif policy_saugumas == [] and float(saugumas) >= 0.3:
  39. print("Slaptazodis saugus!")
  40.  
  41. def saugumo_testas():
  42. print("Saugumo testas")
  43.  
  44.  
  45. #pradzia
  46.  
  47.  
  48. print("Sveiki!")
  49. ivestis = input("Kuria programa naudosite?\n1. Sugeneruoti slaptazodi\n2. Patikrinti slaptazodzio sauguma\nIvestis: ")
  50. if ivestis.isdigit():
  51. if int(ivestis) == 1:
  52. generuoti()
  53. elif int(ivestis) == 2:
  54. saugumo_testas()
  55. else:
  56. print("Pasirinkite teisinga programa!")
  57. elif not ivestis.isdigit():
  58. print("Turite ivesti skaiciu!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement