md5.lua
md5.lua copied to clipboard
Incorrect hashes on small strings
I was double checking my indexes, and found a collision. Surpised, I did some more research:
nothanks@DESKTOP-616042V ~/repos/roguecraft-squadron
$ cat test1.txt
"Computer, what happened to the IEE Bishop?"
nothanks@DESKTOP-616042V ~/repos/roguecraft-squadron
$ cat test1.txt | md5sum.exe
5f0d58eb72664a1e2848b191edfd1bee *-
nothanks@DESKTOP-616042V ~/repos/roguecraft-squadron
$ cat test2.txt
"Computer, what is Miho Takeda's current status?"
nothanks@DESKTOP-616042V ~/repos/roguecraft-squadron
$ cat test2.txt | md5sum.exe
03f3a365b8dfc21ddad179289a0138f6 *-
nothanks@DESKTOP-616042V ~/repos/roguecraft-squadron
$ cat test.lua
md5 = require"src.libs.md5"
print(md5.tohex('"Computer, what happened to the IEE Bishop?"'))
print(md5.tohex('"Computer, what is Miho Takeda\'s current status?"'))
nothanks@DESKTOP-616042V ~/repos/roguecraft-squadron
$ lua test.lua
22436f6d70757465722c207768617420
22436f6d70757465722c207768617420
It seems that I not only found a collision, but also that hashes for smaller strings are not correct.
Am I doing something wrong, or is this a bug?