Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from password_strength import PasswordPolicy
- from password_strength import PasswordStats
- #policy
- policy = PasswordPolicy.from_names(
- length=8, # min length: 8
- uppercase=2, # need min. 2 uppercase letters
- numbers=2, # need min. 2 digits
- special=2, # need min. 2 special characters
- nonletters=2,) # need min. 2 non-letter characters (digits, specials, anything)
- #Variables
- password = ""
- combinations="qwertyuiopasdfghjklzxcxvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM!$%^&*"
- #funkcijos
- def generuoti():
- global password
- global combinations
- i = input("Kokio ilgio slaptazodzio jus norite: ")
- #generuoja skaicius
- try:
- for x in range(int(i)):
- password += random.choice(combinations)
- except:
- print("Klaida!")
- print(password)
- #test
- stats = PasswordStats(password)
- saugumas = stats.strength()
- policy_saugumas = policy.test(password)
- if policy_saugumas != []:
- print("Slaptazodziui truksta: " + str(policy_saugumas))
- elif policy_saugumas == [] and float(saugumas) >= 0.3:
- print("Slaptazodis saugus!")
- def saugumo_testas():
- print("Saugumo testas")
- #pradzia
- print("Sveiki!")
- ivestis = input("Kuria programa naudosite?\n1. Sugeneruoti slaptazodi\n2. Patikrinti slaptazodzio sauguma\nIvestis: ")
- if ivestis.isdigit():
- if int(ivestis) == 1:
- generuoti()
- elif int(ivestis) == 2:
- saugumo_testas()
- else:
- print("Pasirinkite teisinga programa!")
- elif not ivestis.isdigit():
- print("Turite ivesti skaiciu!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement