In this project, we won't conserve RAM, but just find cycles in hash functions.
If you hash a starting value, and then hash that hash, and repeat this process, you don't keep getting different numbers forever. Eventually you get a repeated value, and after that all further values are repeats, going in a loop, as shown below.
Figure from Serious Cryptography
import hashlib
print hashlib.new('md5', "a").hexdigest()
The md5 hash appears,
starting with 0cc,
as shown below.
Checking with an online MD5 calculator shows that this hash is correct, as shown below.
In Python, execute this code, as shown below.
import hashlib
print hashlib.new('md5', "a").hexdigest()[-2:]
The result is 61,
the last two characters in the hash,
as shown below.
In Python, execute this code, as shown below.
import hashlib
h = "a"
for i in range(50):
h = hashlib.new('md5', h).hexdigest()[-2:]
print h,
Adjusting the width of the window makes it easy
to see when the values start repeating,
as shown below.
Enter the first repeated hash value into the form below to record your success.
Enter the first repeated hash value into the form below to record your success.
Start the truncated hash you used above with an initial string of "password" instead of "a".
Enter the first repeated hash value into the form below to record your success.