PHP md5_file() Function

PHP md5_file() Function returns the MD5 hash of the file.

It returns the hash as a 16 or 32 character hexadecimal number. The md5_file() function uses the RSA DATA security, MD5 Message-Digest Algorithm. PHP md5_file() is predefined function.

Syntax :

md5_file(file,binary) ;

Parameter Values,

file: Required. It  takes a file name as input.
binary : Optional. Specifies hex or binary output format.
            TRUE - Raw 16 character binary format
            FALSE - Default. 32 character hex number

md5_file() function returns encrypted string for file. We can not get decrypted value of encrypted string returned by md5_file() function.

If file is not found, then it gives warning as failed to open stream: No such file or directory

md5() function returns md5 hash of string whereas md5_file() returns hash of file.

Let's see below example to understand md5_file() function.

Example :

$hex = md5_file("");
echo "<br>It returns 32 character hex number :".$hex; // display MD5 hash of a file

$binary= md5_file("",TRUE); // binary parameter is TRUE
echo "<br>It returns Raw 16 character binary format :".$binary; // display MD5 hash of a file



Leave a Reply

Your email address will not be published. Required fields are marked *