note 119576 added to function.hash-equals

From: Date: Sun, 10 Jul 2016 16:00:13 +0000
Subject: note 119576 added to function.hash-equals
Groups: php.notes 
Request: Send a blank email to php-notes+get-205944@lists.php.net to get a copy of this message
asphp has done a great job and that one of Markus P. N. is also good too. However i made my own more concise version of the asphp code that supports different lenght strings and i used the same tests of Markus in order see how it works. <?php if(!function_exists('hash_equals')) { function hash_equals($known_string, $user_string) { $ret = 0; if (strlen($known_string) !== strlen($user_string)) { $user_string = $known_string; $ret = 1; } $res = $known_string ^ $user_string; for ($i = strlen($res) - 1; $i >= 0; --$i) { $ret |= ord($res[$i]); } return !$ret; } } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 195.32.8.222 ---- Manual Page -- http://php.net/manual/en/function.hash-equals.php Edit -- https://master.php.net/note/edit/119576 Del: integrated -- https://master.php.net/note/delete/119576/integrated Del: useless -- https://master.php.net/note/delete/119576/useless Del: bad code -- https://master.php.net/note/delete/119576/bad+code Del: spam -- https://master.php.net/note/delete/119576/spam Del: non-english -- https://master.php.net/note/delete/119576/non-english Del: in docs -- https://master.php.net/note/delete/119576/in+docs Del: other reasons-- https://master.php.net/note/delete/119576 Reject -- https://master.php.net/note/reject/119576 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205944) next »