Monday, 29 September 2014

md5_file in PHP

PHP md5_file() function utilized to the calculated MD5 hash(the hash as a 32-character hexadecimal number) of a specified file.

PHP md5_file() function uses the "RSA Data Security, Inc. md5 Message-Digest Algorithm" and returns that hash.

Syntax:

md5_file(file,raw)
file : Required. The input file.

raw : Optional. Defines hex or binary output format: 
             TRUE – Returns the digest in raw binary format with a length of 16
             FALSE – Default. Returns the digest in raw hex format with a length of 32.

Example:

<?php
$file_name = "test_file.txt";
$md5_file_op = md5_file($file_name);
echo $md5_file_op;
?>
Output will be:
ca382c0ca77fce63ae7f1b7d3fdddde1

0 comments:

Post a Comment