note 89563 modified in function.hash by danbrown

From: Date: Fri, 13 Mar 2009 17:56:48 +0000
Subject: note 89563 modified in function.hash by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151845@lists.php.net to get a copy of this message
@Kevin. I tried your function, but I was able to get the same hash for different passwords. <?php function doubleSalt($toHash,$username){ $password = str_split($toHash,strlen($toHash)/2); $hash = hash('whirlpool', $username.$password[0].'centerSalt'.$password[1]); return $hash; } ?> One Example: <?php echo doubleSalt('mypassword223','sunil'); echo "<br />"; echo doubleSalt('mypassword224','sunil'); ?> OUTPUT: 96c29a984fb86e61c8cb8bf5584a5d7a79691f4 6361c079f38815abf180a9bc8e887dcefb556e1 bc8b3a771ff3da2a9841dea665bf2b7ad8f541 e09ed10e37a0 96c29a984fb86e61c8cb8bf5584a5d7a79691f4 6361c079f38815abf180a9bc8e887dcefb556e1 bc8b3a771ff3da2a9841dea665bf2b7ad8f541 e09ed10e37a0 --was-- @Kevin. I tried your function, but I was able to get the same hash for different passwords. function doubleSalt($toHash,$username){ $password = str_split($toHash,strlen($toHash)/2); $hash = hash('whirlpool', $username.$password[0].'centerSalt'.$password[1]); return $hash; } One Example: echo doubleSalt('mypassword223','sunil'); echo "<br />"; echo doubleSalt('mypassword224','sunil'); OUTPUT: 96c29a984fb86e61c8cb8bf5584a5d7a79691f4 6361c079f38815abf180a9bc8e887dcefb556e1 bc8b3a771ff3da2a9841dea665bf2b7ad8f541 e09ed10e37a0 96c29a984fb86e61c8cb8bf5584a5d7a79691f4 6361c079f38815abf180a9bc8e887dcefb556e1 bc8b3a771ff3da2a9841dea665bf2b7ad8f541 e09ed10e37a0 http://php.net/manual/en/function.hash.php

« previous php.notes (#151845) next »