Skip to content

Commit c769746

Browse files
authored
Reverse hash_equals parameters (#4733)
As stated in the document, the user provided string is supposed to be the second parameter. Whereas before this pull request, the user provided string is the first parameter.
1 parent 7100979 commit c769746

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

reference/hash/functions/hash-equals.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ $secretKey = '8uRhAeH89naXfFXKGOEj';
7676
$value = 'username=rasmuslerdorf';
7777
$signature = '8c35009d3b50caf7f5d2c1e031842e6b7823a1bb781d33c5237cd27b57b5f327';
7878
79-
if (hash_equals(hash_hmac('sha256', $value, $secretKey), $signature)) {
79+
if (hash_equals($signature, hash_hmac('sha256', $value, $secretKey))) {
8080
echo "The value is correctly signed.", PHP_EOL;
8181
} else {
8282
echo "The value was tampered with.", PHP_EOL;

0 commit comments

Comments
 (0)