note 118384 deleted from function.hash-equals by cmb
| From: | cmb@php.net | Date: | Thu, 29 Jul 2021 12:42:19 +0000 |
| Subject: | note 118384 deleted from function.hash-equals by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216686@lists.php.net to get a copy of this message | ||
Note Submitter: David Grudl
----
Very short timing attack safe string comparison for PHP < 5.6
<?php
function hash_equals($a, $b) {
return substr_count($a ^ $b, "\0") * 2 === strlen($a . $b);
}
?>