def get_crypto_hash(password: str) -> str:
return hashlib.sha256(password.encode()).hexdigest()
def check_password(expected_crypto_hash: str,
possible_password: str) -> bool:
➋
actual_crypto_hash = get_crypto_hash(possible_password)
return expected_crypto_hash == actual_crypto_hash
def crack_password(crypto_hash: str, length: int) -> None:
print("Processing number combinations sequentially")
start_time = time.perf_counter()
➌
combinations = get_combinations(length=length)
for combination in combinations:
if check_password(crypto_hash, combination):
print(f"PASSWORD CRACKED: {combination}")
break
process_time = time.perf_counter() - start_time
print(f"PROCESS TIME: {process_time}")