-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d338926
commit 2952bbe
Showing
4 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from datetime import timedelta | ||
from password_entropy import tier, calculate_password_entropy, TIERS | ||
import json | ||
|
||
# Функция для загрузки паролей и их тиров из JSON файла | ||
def load_passwords(filename): | ||
with open(filename, 'r', encoding='utf-8') as file: | ||
data = json.load(file) | ||
return data | ||
|
||
# Функция для тестирования паролей | ||
def test_passwords(filename): | ||
password_data = load_passwords(filename) | ||
|
||
# Количество совпадений по тирам | ||
correct_predictions = {tier_name : 0 for tier_name in TIERS} | ||
|
||
for expected_tier, passwords in password_data.items(): | ||
print(f"Testing {expected_tier} passwords:") | ||
for password in passwords: | ||
entropy = calculate_password_entropy(password) | ||
ttd = timedelta(seconds=10e-9 * pow(2, entropy)) | ||
predicted_tier = tier(ttd) | ||
|
||
print(f"Password: {password}, Predicted Tier: {predicted_tier}, Entropy: {entropy}") | ||
|
||
if expected_tier == predicted_tier: | ||
correct_predictions[predicted_tier] += 1 | ||
|
||
print("\nResults:") | ||
for tier_name, correct_count in correct_predictions.items(): | ||
print(f"Correct predictions for {tier_name} tier: {correct_count / len(password_data[tier_name])}") | ||
|
||
if __name__ == "__main__": | ||
test_passwords('test_passwords.json') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"Pathetic": [ | ||
"password", | ||
"123456" | ||
"12345678" | ||
], | ||
"Low": [ | ||
"Passw0rd", | ||
"securepwd" | ||
], | ||
"Medium": [ | ||
"SecureP@ssword", | ||
"complexPW123!" | ||
], | ||
"High": [ | ||
"VeryC0mpl3xP@ss", | ||
"NewPWD$ecure!" | ||
], | ||
"Extreme": [ | ||
"Ultr@C0mplexPa$$w0rd", | ||
"Th!sIsAV3ryL0ng&P@ss#0rd" | ||
] | ||
} |