Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add incremental MD5 function (feature request) #8

Closed
ghost opened this issue Jul 1, 2016 · 3 comments
Closed

Add incremental MD5 function (feature request) #8

ghost opened this issue Jul 1, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 1, 2016

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 65a8e27d8879283831b664bd8b7f0ad4
state = 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

@tst2005
Copy link

tst2005 commented Jul 1, 2016

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,

@kikito
Copy link
Owner

kikito commented Jul 2, 2016

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.

@ghost ghost mentioned this issue Jul 2, 2016
@kikito
Copy link
Owner

kikito commented Jul 15, 2016

Implemented in #10

@kikito kikito closed this as completed Jul 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants