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 is used to specify the known length string.
- $usr_str: This parameter is used to specify the user-supplied string.
Return Value: This function returns True if both strings are equal, False otherwise.
Below programs illustrate the hash_equals() function in PHP:
Program 1:
<?php // PHP program to illustrate // hash_equals function $known_str = crypt('GFG', 'Hello-GFG'); $usr_str = crypt('GFG', 'Hello-GFG'); // Compare bith strings $res = hash_equals($known_str, $usr_str); // Display result var_dump($res); ?> |
bool(true)
Program 2:
<?php // PHP program to illustrate // hash_equals function $known_str = crypt('GFG', 'Hello-GFG'); $usr_str = crypt('GeeksforGeeks', 'Hello-GFG'); // Compare bith strings $res = hash_equals($known_str, $usr_str); // Display result var_dump($res); ?> |
bool(false)
Reference: http://php.net/manual/en/function.hash-equals.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- PHP | ord() Function
- p5.js | nf() Function
- D3.js | d3.map.set() Function
- p5.js | arc() Function
- p5.js | box() Function
- p5.js | nfc() function
- CSS | hsl() Function
- CSS | rgb() Function
- PHP | tan( ) Function
- D3.js | d3.map.has() Function
- PHP | exp() Function
- D3.js | d3.min() function
- D3.js | d3.map.get() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



