@@ -64,13 +64,14 @@ def is_pwned(password):
6464
6565 try :
6666 res = requests .get (url , timeout = 5 )
67+ res .raise_for_status ()
6768 for line in res .text .splitlines ():
6869 h , count = line .split (":" )
6970 if h == suffix :
70- return True
71- return False
71+ return True , False
72+ return False , False
7273 except Exception :
73- return False
74+ return False , True
7475
7576
7677def update_meter (score ):
@@ -137,15 +138,22 @@ def check_strength():
137138
138139 entropy_bits = password_entropy (password )
139140 crack = crack_time (entropy_bits )
140- pwned = is_pwned (password )
141+ pwned , pwned_failed = is_pwned (password )
142+
143+ if pwned_failed :
144+ breach_status = "⚠️ Breach check unavailable"
145+ elif pwned :
146+ breach_status = "⚠️ Found in breaches!"
147+ else :
148+ breach_status = "✅ Not found"
141149
142150 result = ""
143151 result += "Password Strength Check\n "
144152 result += "------------------------\n "
145153 result += f"Strength: { strength } \n "
146154 result += f"Entropy: { entropy_bits :.2f} bits\n "
147155 result += f"Estimated Crack Time: { crack } \n "
148- result += f"Breach Status: { '⚠️ Found in breaches!' if pwned else 'Not found' } \n "
156+ result += f"Breach Status: { breach_status } \n "
149157
150158 if missing :
151159 result += "\n Suggestions:\n "
@@ -157,7 +165,7 @@ def check_strength():
157165 text_output .insert (tk .END , result )
158166 text_output .config (state = "disabled" )
159167
160- if strength == "Strong" and not pwned :
168+ if strength == "Strong" and not pwned and not pwned_failed :
161169 add_to_history (password )
162170
163171
0 commit comments