Look at the code:
>>> import hashlib>>> md5=hashlib.md5 () >>> md5.update (' 123 '. Encode (' Utf-8 ')) >> > Print (Md5.hexdigest ()) 202cb962ac59075b964b07152d234b70>>> md5.update (' 123 '. Encode (' Utf-8 ')) > >> print (Md5.hexdigest ()) 4297F44B13955235245B2497399D7A93//have not found the same result as above for the string "123" MD5 encryption
After testing that Md5.update would stitch each string together, we looked at the result of "123123" as follows:
>>> md5=hashlib.md5 ()//redefine md5>>> md5.update (' 123123 '. Encode (' Utf-8 ')) >>> print (md5.he Xdigest ()) 4297F44B13955235245B2497399D7A93//Discovery 123123 and the results above verify that the md5.update is the stitching effect.
To prevent this interference we have to re-instantiate each time:
Redefine every time you use Update: MD5=HASHLIB.MD5 ()
eg
Import HASHLIBF = open (' Top10.md5.txt ', ' w ') p = open (' Top10.txt ', ' r ') for I in P:MD5 = Hashlib.md5 () I=i.strip ()/ /filter white space character md5.update (I.encode (' Utf-8 ')) c=md5.hexdigest () c=c+ ' \ n ' f.write (c)
====top10.txt=======123456password12345678qwerty1234512345678912345671234567890abc123111111=====top10.md5.txt= ==e10adc3949ba59abbe56e057f20f883e5f4dcc3b5aa765d61d8327deb882cf9925d55ad283aa400af464c76d713c07add8578edf8458ce06fbc5bb7 6a58c5ca4827ccb0eea8a706c4c34a16891f84e7b25f9e794323b453885f5181f1b624d0bfcea920f7412b5da7be0cf42b8c93759e807f1fcf82d132f 9bb018ca6738a19fe99a18c428cb38d5f260853678922e0396e79218965eb72c92a549dd5a330112
The md5.update of Python.