[DOC-CVS] [doc-en] master: Reverse hash_equals parameters (#4733)
[email protected] (Devin Gammill via GitHub)
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Devin Gammill (dmgsoftware)
Committer: GitHub (web-flow)
Pusher: nielsdos
Date: 2025-06-19T22:53:46+02:00
Commit: https://github.com/php/doc-en/commit/c769746c03d62089a5414f07b505cf24be068acc
Raw diff: https://github.com/php/doc-en/commit/c769746c03d62089a5414f07b505cf24be068acc.diff
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.
Changed paths:
M reference/hash/functions/hash-equals.xml
Diff:
diff --git a/reference/hash/functions/hash-equals.xml b/reference/hash/functions/hash-equals.xml
index eaf6836ebd16..1ab4c7d6352a 100644
--- a/reference/hash/functions/hash-equals.xml
+++ b/reference/hash/functions/hash-equals.xml
@@ -76,7 +76,7 @@ $secretKey = '8uRhAeH89naXfFXKGOEj';
$value = 'username=rasmuslerdorf';
$signature = '8c35009d3b50caf7f5d2c1e031842e6b7823a1bb781d33c5237cd27b57b5f327';
-if (hash_equals(hash_hmac('sha256', $value, $secretKey), $signature)) {
+if (hash_equals($signature, hash_hmac('sha256', $value, $secretKey))) {
echo "The value is correctly signed.", PHP_EOL;
} else {
echo "The value was tampered with.", PHP_EOL;