PHP Hash_hmac () function

hash_hmac | PHP

Syntax:
string hash_hmac ($algo, $msg, $key, $raw_opt)
Parameters:This function takes four parameters as above and described below.
  • $algo:This is a required parameter and is used to specify the selected algorithm hashing. "Md5", "sha256", "sha1".
  • $msg:This parameter is used to store the message to be hashed.
  • $key:This parameter is used to specify the shared secret used to generate the HMAC variant of the message digest.
  • $raw_opt:This parameter is used to store a boolean value. If set to True, then it returns raw binary data, and if set to False, then it returns lowercase hexadecimal output values.
Return value: this function returns the string containing the computed message digest in lowercase.The following programs illustrate the hash_hmac() function in PHP:
Program 1:  
// PHP illustration program
// hash_hmac function echo hash_hmac ( `md5` , `GeeksforGeeks A Computer Science Portal` ,
`GFG_DATA` ); ?>
Exit:
65f3fc3c9085077f44ade6ce2d21eba4
Program 2:  
// PHP illustration program
// hash_hmac function echo hash_hmac ( `md5` , `GeeksforGeeks A Computer Science Portal` , `GFG_DATA` , false) ... "" ; echo hash_hmac ( `md5` , `GeeksforGeeks A Computer Science Portal` , `GFG_DATA` , true ); ?>
Exit:
65f3fc3c9085077f44ade6ce2d21eba4 eóü DæÎ -! ë¤
Link: http: // php. net / manual / en / function.hash-hmac.php



PHP Hash_hmac () function: StackOverflow Questions

Get Solution for free from DataCamp guru