Forum Moderators: coopster

Message Too Old, No Replies

Fast md5 file hashing in php

What's the fastest way?

         

Garfield

12:05 pm on May 10, 2004 (gmt 0)

10+ Year Member



Hi folks,

I need to hash files with md5. Filesize is between 3 and 20 MB. Currently I use file_get_contents to load the entire file into a string and then hash it. This is not really slow, but auite memory consuming since files have to be read entirely to memory.

Is there a better way to do hashing in php? It has to be fast, but a little less memory consuming would be great. Would it be possible to use the UNIX md5sum command to hash the files and then parse the output?

Thanks in advance!

Forse

12:32 pm on May 10, 2004 (gmt 0)

10+ Year Member



well u could do:

exec('md5sum '.$filename);

but I am not sure if that's a better way