From 2d4141937a123c42d9e32d464dc821f774dacca5 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Mon, 4 Sep 2023 16:57:28 +0200 Subject: [PATCH] md5 stuff --- src/md5.py | 4 ++++ src/md5range.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/md5.py create mode 100644 src/md5range.py diff --git a/src/md5.py b/src/md5.py new file mode 100644 index 0000000..a4218b7 --- /dev/null +++ b/src/md5.py @@ -0,0 +1,4 @@ +import hashlib +import sys +hashed = hashlib.md5(sys.argv[1].encode()) +print(hashed.digest().hex()) diff --git a/src/md5range.py b/src/md5range.py new file mode 100644 index 0000000..e546572 --- /dev/null +++ b/src/md5range.py @@ -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)