md5 stuff

This commit is contained in:
Christoph J. Scherr 2023-09-04 16:57:28 +02:00
parent d3483e229e
commit 2d4141937a
2 changed files with 24 additions and 0 deletions

4
src/md5.py Normal file
View File

@ -0,0 +1,4 @@
import hashlib
import sys
hashed = hashlib.md5(sys.argv[1].encode())
print(hashed.digest().hex())

20
src/md5range.py Normal file
View File

@ -0,0 +1,20 @@
import hashlib
import sys
BASE: str = "foobar"
MAX = 1000000
SEARCH = "00"
results: list[str] = []
count = 0
for i in range(0, MAX):
num: str = ("%06d" % i)
current = BASE + num
results.append(hashlib.md5(current.encode()).digest().hex())
for res in results:
if SEARCH == res[:2]:
count += 1
print(res)
print(f"\nFound %d digests matching the search" % count)