You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The suggestion by @stejacob in #4 (comment) would not have fixed the issue reported there, but it is sound. Usual C implementations use md5_init, md5_update and md5_done (the names may vary), where md5_update can be called as often as necessary, and md5_done does the padding and calculates the final result. With Lua, the API can be something that is used like this:
-- this should print the MD5 of "Hello, World!" which is 65a8e27d8879283831b664bd8b7f0ad4state=md5.new()
state:update("Hello")
state:update(", World!")
result=state:finish()
print(md5.tohex(result))
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
The text was updated successfully, but these errors were encountered:
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.
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.
The suggestion by @stejacob in #4 (comment) 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
The text was updated successfully, but these errors were encountered: