Skip to content

Instantly share code, notes, and snippets.

@dobrovolsky
Last active May 18, 2023 21:49
Show Gist options
  • Save dobrovolsky/52f0b8624ee130262518235b7a1deae6 to your computer and use it in GitHub Desktop.
Save dobrovolsky/52f0b8624ee130262518235b7a1deae6 to your computer and use it in GitHub Desktop.
#!/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