md5_file() function in PHP || PHP md5_file() function

md5_file() function in php

Last Updated by Pooja Chikara 14-May-20

0 248


PHP md5_file() function is used to generate the md5 hash of a file. It is an inbuilt function of PHP. This function returns md5 hashed on success and returns FALSE in case of failure.

Syntax:

md5_file($file,$format)

1. $file is a file on which this function is operated. It is mandatory.

2. $format is the Boolean parameter which specifies the format of the result. It is optional. This parameter has two possible values.

a. TRUE: it represents 16 character binary format.

b. FALSE: it represents 32 characters hex number. By default it is selected.


File: test.txt

md5_file() function in php

<?php
$file="test.txt";
$hashed_string=md5_file($file,FALSE);
echo "Hashed string is : $hashed_string";
?>

Output:

md5_file() function in php


Share:


Leave a Reply


Comments
    Waiting for your comments