function compute_md5sum(&$data)
    {

        if (function_exists("hash_init") && is_resource($data)) {
            $ctx = hash_init('md5');
            while (!feof($data)) {
                $buffer = fgets($data, 65536);
                hash_update($ctx, $buffer);
            }
            $md5 = hash_final($ctx, false);
            rewind($data);
        } elseif ((string)is_file($data)) {
            $md5 = md5_file($data);
        } else {
            $md5 = md5($data);
        }
        return $md5;
    }
function compute_md5sum(&$data)
    {

        if (function_exists("hash_init") && is_resource($data)) {
            $ctx = hash_init('md5');
            while (!feof($data)) {
                $buffer = fgets($data, 65536);
                hash_update($ctx, $buffer);
            }
            $md5 = hash_final($ctx, false);
            rewind($data);
        } elseif ((string)is_file($data)) {
            $md5 = md5_file($data);
        } else {
            $md5 = md5($data);
        }
        return $md5;
    }
function compute_md5sum ( & $ data ) { if ( function_exists ( "hash_init" ) && is_resource ( $ data ) ) { $ ctx = hash_init ( 'md5' ) ; while ( ! feof ( $ data ) ) { $ buffer = fgets ( $ data , 65536 ) ; hash_update ( $ ctx , $ buffer ) ; } $ md5 = hash_final ( $ ctx , false ) ; rewind ( $ data ) ; } elseif ( ( string ) is_file ( $ data ) ) { $ md5 = md5_file ( $ data ) ; } else { $ md5 = md5 ( $ data ) ; } return $ md5 ; }
Compute the MD5 checksum

Calculate the MD5 checksum on either a PHP resource or data.  The argument
may either be a local filename, open resource for reading, or a string.

<b>WARNING:</b> if you are uploading a big file over a stream
it could get very slow to compute the md5 you probably want to
set the $verify parameter to False in the write() method and
compute yourself the md5 before if you have it.

@param filename|obj|string $data filename, open resource, or string
@return string MD5 checksum hexidecimal string
Compute the MD5 checksum