note 115635 added to function.hash-equals
| From: | asphp at dsgml dot com | Date: | Thu, 28 Aug 2014 19:48:49 +0000 |
| Subject: | note 115635 added to function.hash-equals | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200336@lists.php.net to get a copy of this message | ||
To transparently support this function on older versions of PHP use this:
<?php
if(!function_exists('hash_equals')) {
function hash_equals($str1, $str2) {
if(strlen($str1) != strlen($str2)) {
return false;
} else {
$res = $str1 ^ $str2;
$ret = 0;
for($i = strlen($res) - 1; $i >= 0; $i--) $ret |= ord($res[$i]);
return !$ret;
}
}
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 2601:7:9f00:54d:22cf:30ff:fe05:22e8
----
Manual Page -- http://php.net/manual/en/function.hash-equals.php
Edit -- https://master.php.net/note/edit/115635
Del: integrated -- https://master.php.net/note/delete/115635/integrated
Del: useless -- https://master.php.net/note/delete/115635/useless
Del: bad code -- https://master.php.net/note/delete/115635/bad+code
Del: spam -- https://master.php.net/note/delete/115635/spam
Del: non-english -- https://master.php.net/note/delete/115635/non-english
Del: in docs -- https://master.php.net/note/delete/115635/in+docs
Del: other reasons-- https://master.php.net/note/delete/115635
Reject -- https://master.php.net/note/reject/115635
Search -- https://master.php.net/manage/user-notes.php