note 113528 added to function.hash-pbkdf2

From: Date: Fri, 25 Oct 2013 15:30:48 +0000
Subject: note 113528 added to function.hash-pbkdf2
Groups: php.notes 
Request: Send a blank email to php-notes+get-197321@lists.php.net to get a copy of this message
this snippet was posted over a year ago on a dutch PHP community: (reference/source: http://www.phphulp.nl/php/script/beveiliging/pbkdf2-een-veilige-manier-om-wachtwoorden-op-te-slaan/1956/pbkdf2php/1757/) <?php /** * @author Chris Horeweg * @package Security_Tools */ function pbkdf2($password, $salt, $algorithm = 'sha512', $count = 20000, $key_length = 128, $raw_output = false) { if(!in_array($algorithm, hash_algos(), true)) { exit('pbkdf2: Hash algoritme is niet geinstalleerd op het systeem.'); } if($count <= 0 || $key_length <= 0) { $count = 20000; $key_length = 128; } $hash_length = strlen(hash($algorithm, "", true)); $block_count = ceil($key_length / $hash_length); $output = ""; for($i = 1; $i <= $block_count; $i++) { $last = $salt . pack("N", $i); $last = $xorsum = hash_hmac($algorithm, $last, $password, true); for ($j = 1; $j < $count; $j++) { $xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true)); } $output .= $xorsum; } if($raw_output) { return substr($output, 0, $key_length); } else { return base64_encode(substr($output, 0, $key_length)); } } ---- Server IP: 64.71.164.2 Probable Submitter: 87.211.29.232 ---- Manual Page -- http://php.net/manual/en/function.hash-pbkdf2.php Edit -- https://master.php.net/note/edit/113528 Del: integrated -- https://master.php.net/note/delete/113528/integrated Del: useless -- https://master.php.net/note/delete/113528/useless Del: bad code -- https://master.php.net/note/delete/113528/bad+code Del: spam -- https://master.php.net/note/delete/113528/spam Del: non-english -- https://master.php.net/note/delete/113528/non-english Del: in docs -- https://master.php.net/note/delete/113528/in+docs Del: other reasons-- https://master.php.net/note/delete/113528 Reject -- https://master.php.net/note/reject/113528 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197321) next »