lunarmodules / md5

MD5 offers basic cryptographic facilities for Lua 5.1.
https://lunarmodules.github.io/md5/
110 stars 63 forks source link

md5_update behaves differently from other implementations. #15

Open Gemini2015 opened 1 year ago

Gemini2015 commented 1 year ago
md5_init(m);  
md5_update(m, "hello", strlen("hello"));  
md5_update(m, "world", strlen("world"));  
md5_finish(m, hash);  

hash: a48b171ee450c14dab8e7162cdce3f8d

md5_init(m);  
md5_update(m, "helloworld", strlen("helloworld"));  
md5_finish(m, hash);  

hash: fc5e038d38a57032085441e7fe7010b0

In Python or other C implementations, eg RFC 1321

hash_md5 = hashlib.md5()
hash_md5.update("hello")
hash_md5.update("world")
print(hash_md5.hexdigest())

hash: fc5e038d38a57032085441e7fe7010b0

hash_md5 = hashlib.md5()
hash_md5.update("helloworld")
print(hash_md5.hexdigest())

hash: fc5e038d38a57032085441e7fe7010b0

niu2x commented 3 months ago

i find the same bug., after debug several hours, very sadly

Gemini2015 commented 3 months ago

i find the same bug., after debug several hours, very sadly

take a look at my fork, I fixed the bug, and It works welll. https://github.com/Gemini2015/md5

niu2x commented 3 months ago

i find the same bug., after debug several hours, very sadly

take a look at my fork, I fixed the bug, and It works welll. https://github.com/Gemini2015/md5

good news . i didn't got your reply that day. i had enjoy openssl for this job.