I'm MD5'ing a large file, it takes lots of time.
Before I have the file on disc I've got it in many chunks in a DB, then I dump it to the disc.
Is there a way to perform an ongoing md5 calculation while I dump it to the disc chunk by chunk instead of having to do the entire calculation later ?
They're coming to take me away, Ha-haaa!
Advanced .NET Debugging Blog
My personal blog
Unfortunately (as you probably already know) the built in MD5 function of PHP is not incremental and can only do that on a given string or so.
Python, on the other hand, has a built-in MD5 implementation that can work incrementally, adding more chunks to be calculated and the calculate the digest at the end.
The question is, how are you calculating the hash, is it by executing a command through PHP for the md5sum utility, or reading everything up into PHP and using its MD5 function?
I've got a situation where I have a file stored in many db records.I read these records and dump into a file.then I execute md5_file or something like that to get the hash.If all the data passes through me it makes sense to do it incrementally and save at least the disc reading of all the file.Storing the whole thing in memory is too big as well.
I bet someone wrote this for php, i'll go search, the word I was missing was 'incremental'.
ooo i can edit my replies, nice...
here's an md5 implementation, if i had time i would try to incrementalize it:
http://www.tecknik.net/md5/md5.phps
You have two other options though:
Got an answer for ohadpr? Would you like to comment on the posted answers, or vote for the one which you think is the best?
Sign up for a free account, or sign in (if you're already a member).
Other people asked questions on similar topics, check out the answers they received:
Other people asked questions on various topics, and are still waiting for answer. Would be great if you can take a sec and answer them