I have a relatively simple text processing algorithm that imports some words from a text file and produces a phrase. The algorithm has a second path it can take if a setting flag (a simple constant) is enabled. The second path basically is an additional list comprehension that filters out some words.
In both cases the algorithm produces the same phrase (str1
and str2
below) but the md5 hash of each phrase is different. I confirmed this using the Python shell:
(NOTE: the phrase and hash values are not the actual values being used)
>>> import hashlib
>>>
>>> str1 = "some phrase"
>>> str2 = "some phrase"
>>> str1 == str2
True
>>>
>>> md5 = hashlib.md5()
>>>
>>> md5.update(str1.encode('utf-8'))
>>> hash_1 = md5.hexdigest()
>>>
>>> md5.update(str2.encode('utf-8'))
>>> hash_2 = md5.hexdigest()
>>>
>>> print(hash_1)
34281bdd108d35dec09dd6599bc144gf
>>> print(hash_2)
0670d0df2506c7gf0d5ee27190g2d919
How is this possible?