Last active
May 18, 2023 21:49
-
-
Save dobrovolsky/52f0b8624ee130262518235b7a1deae6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
import hashlib | |
import sys | |
from getpass import getpass | |
verbose = any(verbose in sys.argv for verbose in ['-v', '--verbose']) | |
password = getpass('Password: ') | |
assert password | |
iterations = int(getpass('Iteratons: ') or 0) | |
algorithm = getpass('Algorithm: ') or 'sha256' | |
hash_function = getattr(hashlib, algorithm) | |
res = hash_function(password.encode()).hexdigest() | |
iterator = range(iterations) | |
if verbose: | |
try: | |
from rich.progress import track | |
except ImportError: | |
... | |
else: | |
iterator = track(iterator, description="Processing...") | |
print('Algorithm:', algorithm) | |
print('Iterations:', iterations) | |
print('First hash:', res[0:4]) | |
for i in iterator: | |
res = hash_function(res.encode()).hexdigest() | |
print(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment