-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
42 lines (34 loc) · 1.3 KB
/
graph.py
File metadata and controls
42 lines (34 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import pandas as pd
import matplotlib.pyplot as plt
import joblib
MODEL_FILE = "password_strength_model.pkl"
DATASET_FILE = "password_dataset.csv"
df = pd.read_csv(DATASET_FILE)
model = joblib.load(MODEL_FILE)
X = df[["length", "has_upper", "has_lower", "has_digit", "has_symbol", "entropy"]]
y_pred = model.predict(X)
plt.figure(figsize=(7,5))
colors = ['red' if score < 0.4 else 'orange' if score < 0.7 else 'green' for score in y_pred]
plt.scatter(df["entropy"], df["length"], c=colors, label=colors, alpha=0.7)
plt.xlabel("Entropy (bits)")
plt.ylabel("Password Length")
plt.title("Password Complexity vs Model Predicted Strength")
plt.show()
plt.figure(figsize=(7,5))
plt.scatter(df["entropy"], y_pred, alpha=0.7, c='blue')
plt.xlabel("Entropy (bits)")
plt.ylabel("Predicted Strength Score (0=weak, 1=strong)")
plt.title("AI Predicted Strength vs Password Entropy")
plt.ylim(0,1)
plt.show()
classical_time_sec = 2**df["entropy"] / 1e9
quantum_time_sec = 2**(df["entropy"]/2) / 1e9
plt.figure(figsize=(7,5))
plt.scatter(df["entropy"], classical_time_sec, label="Classical", alpha=0.6)
plt.scatter(df["entropy"], quantum_time_sec, label="Quantum", alpha=0.6)
plt.yscale("log")
plt.xlabel("Entropy (bits)")
plt.ylabel("Crack Time (seconds, log scale)")
plt.title("Classical vs Quantum Crack Time")
plt.legend()
plt.show()