Closed ghost closed 8 years ago
Hello,
I think the md5.lua is an old implementation.
For a more modern implementation take a look at lockbox's md5 and his test.
It use update
, finish
and ashex
like you asked.
Regards,
I am not opposed to this, but the time I have very little time to spare on this project. If someone sends me a pull request I can review it and accept it, but I honestly don't have the time to develop a new feature such as this on my own.
Implemented in #10
The suggestion by @stejacob in https://github.com/kikito/md5.lua/issues/4#issuecomment-158112037 would not have fixed the issue reported there, but it is sound. Usual C implementations use
md5_init
,md5_update
andmd5_done
(the names may vary), wheremd5_update
can be called as often as necessary, andmd5_done
does the padding and calculates the final result. With Lua, the API can be something that is used like this:The advantage is that when the files are long, it's not necessary to send the whole file in one go: it can be calculated on the fly instead (only the last A,B,C,D and up to 63 bytes of buffer are necessary to be kept between calls, thus saving memory). This would allow calculating the MD5 of files larger than those that fit in memory