py-basic/src/md5range.py
2023-09-04 22:19:23 +02:00

18 lines
373 B
Python
Executable file

#!/usr/bin/env python3
import hashlib
BASE: str = "foobar"
MAX = 1000000
SEARCH = "00"
count = 0
for i in range(0, MAX):
num: str = ("%06d" % i)
current = BASE + num
res = hashlib.md5(current.encode()).digest().hex()
if SEARCH == res[:2]:
count += 1
print("%06d | %s" % (i, res))
print(f"\nFound %d digests matching the search" % count)