PHP | hash_hmac_file() Function Last Updated : 28 Apr, 2023 Comments Improve Suggest changes Like Article Like Report The hash_hmac_file() function is an inbuilt function in PHP that is used to generate a keyed hash value using the contents of a given file. Syntax: string hash_hmac_file( $algo, $file, $key, $raw_opt ) Parameters: This function accepts four parameters as mentioned above and described below. $algo: It is the required parameter that specifies the selected hashing algorithm.$file: This parameter is used to specify the file URL to be hashed.$key: This parameter is used to hold the shared secret key used for generating the HMAC.$raw_opt: If the parameter is set to true then output will be raw binary data and if the parameter is set to False then output will be lowercase exits. Return Value: This function returns a string containing the calculated message digest as lowercase exits. The below programs use the file gfg.txt and the contents of the file are: GeeksforGeeks A Computer Science Portal for Geeks The below programs illustrate the hash_hmac_file() function in PHP. Program 1: php <?php // PHP program to illustrate // hash_hmac_file function // Create a file to calculate hash of file_put_contents('gfg.txt', 'Geeks'); // Display result echo hash_hmac_file('sha1', 'gfg.txt', 'password', false); ?> Output: a5365a345a41ac0780bf63e4d33576560b86163c Program 2: php <?php // PHP program to illustrate // hash_hmac_file function // Create a file to calculate hash of file_put_contents('gfg.txt', 'Geeks'); // Display result echo hash_hmac_file('sha256', 'gfg.txt', 'password') . "</br>"; // Create a file to calculate hash of file_put_contents('gfg.txt', 'Content'); // Display result echo hash_hmac_file('md5', 'gfg.txt', 'password', false); ?> Output: a73af6923445a30fbacd646622b254069f90c2502e63b1025918aa93f2ddca9d a7b2b24ac2334070c42a852fb5ef0c92 Reference: http://php.net/manual/en/function.hash-file.php Comment More infoAdvertise with us Next Article PHP | hash_hmac_file() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | hash_hmac() Function The hash_hmac() function is an inbuilt function in PHP which is used to generate the keyed hash value using the HMAC method. Syntax: string hash_hmac( $algo, $msg, $key, $raw_opt ) Parameters: This function accepts four parameters as mention above and describe below. $algo: It is the required parame 2 min read PHP | hash_file( ) Function The hash_file() function is an inbuilt function in PHP which is used to generate a hash value using the contents of a given file. Syntax: string hash_file( $algo, $file, $raw_opt ) Parameters: This function accept three parameters as mention above and describe below. $algo: It is the required parame 2 min read PHP | hash_hmac_algos() Function The hash_hmac_algos() function is an inbuilt function in PHP that is used to get the list of registered hashing algorithms suitable for the hash_hmac() function. Syntax: array hash_hmac_algos( void ) Parameters: This function does not accept any parameter. Return Value: This function returns an ar 2 min read PHP | hash_final() Function The hash_final() function is an inbuilt function in PHP which is used to finalize an incremental hash and return the resulting digest. Syntax: hash_final( $context, $raw_output ) Parameters: This function accept two parameters as mention above and describe below. $context: This parameter is used to 1 min read PHP is_file( ) Function The is_file() function in PHP is an inbuilt function which is used to check whether the specified file is a regular file or not. The name of the file is sent as a parameter to the is_file() function and it returns True if the file is a regular file else it returns False. Syntax: bool is_file($file) 2 min read PHP | hash_algos() Function The hash_algos() function is an inbuilt function in PHP which is used to return a list of registered hashing algorithms. Syntax: array hash_algos( void ) Parameter: This function does not accepts any parameter. Return Value: This function returns a numerically indexed array which contains the list o 2 min read PHP | hash_equals() Function The hash_equals function() is an inbuilt function in PHP which is used to compares two strings using the same time whether they are equal or not.Syntax: hash_equals( $known_str, $usr_str ) Parameters: This function accept two parameters as mention above and describe below. $known_str: This parameter 1 min read PHP | hash_copy() Function The hash_copy() function is an inbuilt function in PHP which is used to get the copy of hashing context. Syntax: hash_copy( $context ) Parameters: This function accepts single parameter $context which is used to specify the hashing context returned by hash_init() function. Return Value: This functio 1 min read PHP | hash_pbkdf2() Function The hash_pbkdf2() function is an inbuilt function in PHP which is used to generate a PBKDF2 key derivation of a supplied password. Syntax: string hash_pbkdf2( $algo, $pass, $salt, $itr, $len, $raw_opt ) Parameters: This function accept six parameters as mention above and describe below. $algo: It is 2 min read Like