63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
import string
|
|
|
|
def get_charecter_pool_size(password):
|
|
pool_size=0
|
|
|
|
has_lower=False
|
|
has_upper=False
|
|
has_digits=False
|
|
has_symbols=False
|
|
for i in password:
|
|
if i in string.ascii_lowercase:
|
|
has_lower=True
|
|
if i in string.ascii_uppercase:
|
|
has_upper=True
|
|
if i in string.digits:
|
|
has_digits=True
|
|
if i in string.punctuation:
|
|
has_symbols=True
|
|
letters=int(has_lower)+int(has_upper)
|
|
pool_size+=letters*(((((((((((((((((((((((((((((len(string.ascii_letters)-len(string.ascii_lowercase))))))))))))))))))))))))))))))
|
|
if has_digits:
|
|
pool_size+=len(string.digits)
|
|
if has_symbols:
|
|
pool_size+len(string.punctuation)
|
|
return pool_size
|
|
def calculate_combinations(pool_size,length):
|
|
return pool_size**length
|
|
def estimate_crack_time(combinations):
|
|
guesses_per_second=1000000
|
|
time=combinations//guesses_per_second
|
|
return time
|
|
def format_time(seconds):
|
|
hours=seconds//3600
|
|
seconds-=(hours*3600)
|
|
minutes=seconds//60
|
|
seconds-=(minutes*60)
|
|
return f"{hours} hours, {minutes} minutes, {seconds} seconds"
|
|
def get_strength_label(seconds):
|
|
if seconds<=60:
|
|
return "Very weak"
|
|
if seconds<3600:
|
|
return "Weak"
|
|
if seconds<43200:
|
|
return "Moderate"
|
|
if seconds<3.154e+7:
|
|
return "Strong"
|
|
return "Very Strong"
|
|
def main():
|
|
print("This will not account for human behavior, for example, password123 will be very strong according to this cracker, don't use this for something that needs to be secure.\nThis would give you the time it would take to brute force this length at 1 million guesses per second.")
|
|
password=input("Enter your password to check: ")
|
|
length=len(password)
|
|
pool_size=get_charecter_pool_size(password)
|
|
if pool_size<=0:
|
|
print("This is how secure your password is: , there it is, thats the security, it's that insecure, maybe set a real password.")
|
|
quit()
|
|
combinations=calculate_combinations(pool_size,length)
|
|
crack_time=estimate_crack_time(combinations)
|
|
print("Max possible characters:",pool_size)
|
|
print("Possible combinations:",combinations)
|
|
print("Estimated crack time:",format_time(crack_time))
|
|
print("Your password is",get_strength_label(crack_time))
|
|
|
|
main() |