Php md5, is there a way to do an ongoing md5 calculation of a huge buffer ?

 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 ? 

 


Share Send to a friend Watch Report
 

Best Answer

 
207 helpful answers

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? 

Posted 2006-12-15T10:54:31Z
Helpful?(3)
Rated as Best Answer

 

All Answers
Order by

 

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 

Posted 2006-12-15T14:18:30Z
 
207 helpful answers

They're coming to take me away, Ha-haaa!

Advanced .NET Debugging Blog

My personal blog

You have two other options though:

  1. Adding Python support to your web server and perform this operation through Python. Start taking the file chunks from the database within Python and use its built-in md5.

  2. Instead of taking various MD5 implementations, just take the one from Python and translate it to PHP Laughing
 

Posted 2006-12-17T09:10:02Z

Sign in to participate

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).

Explore Related Questions

Other people asked questions on similar topics, check out the answers they received:


Q:

Need help with editing a php website

I purchased a website and domain name. I need to update the site with my google adsense and paypal info. the site has a ebook ...
Submitted by Thomas   1 year ago.
  • viewed 166 times
Last answer posted 9 days ago by Reynold Hugh


Q:

Need help with php programmed website to change the google adsense account info and paypal info

php programmer near pottstown pennsylvania 19464 I purchased a adsense website that is programmed in php I need to change the ...
Submitted by Thomas   1 year ago.
  • viewed 120 times


Q:

I want to show image but do php script ? what can ...

i want to show image but do php script ? what can i do
Submitted by aboody2006   2 years ago.
  • viewed 358 times



» More...

Explore Related Posts in Forums

Getting Oracle's MD5 to match PHP's MD5

Hi all, I'm trying to compare an MD5 checksum generated by PHP to one generated by Oracle 10g //php md5 print md5('testingthemd5function'); print ' '; //oracle md5 $... It appears that what's being printed from the Oracle query is the raw bytestream of the md5

Problem with md5(md5($salt).md5($pass))

Salt).md5($pass)) [PHP] module. I know that the passwords is c0ncepts and when I use the hash not crack it. The hash:salt was the following: 94e7c5cc4d957613e8e0d4d9207c0c4c:aeByL and I selected md5(md5... I have just downloaded the version 2.4.2.1 of PasswordsPro and was about to crack some passwords. I included a control (previously...

What's the difference between SHA and MD5 (in PHP)?

When you're hashing a password (or anything else) in PHP, does it make any difference if you use of the algorithms that is distributed with PHP or any implementation. They produce the same result (md5 in php produces the same result as md5 in any other language). Yes, there's a difference. MD5
» More...
Powered by
Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
ADVERTISEMENT
AOL Autos Q&A is powered by Yedda an AOL Company
Copyright © 2006-2009, Yedda Inc. and respective copyright owners