note 72432 deleted from function.md5 by nlopess
| From: | nlopess@php.net | Date: | Thu, 18 Jan 2007 16:23:13 +0000 |
| Subject: | note 72432 deleted from function.md5 by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121893@lists.php.net to get a copy of this message | ||
Note Submitter: boris d0t christ at laposte d0t net
----
Hello ! I have created a little function to use several md5(), because md5() is easily crackable...
<?php
function poly_md5($str, $nbr_fois = 2) {
//for more safety (md5('needle') is easily crackable), use poly_md5($str, 2) is
equivalent to md5(md5($str))
//md5(md5('str')) is uncrackable
//scalar $str, mixed $nbr_fois (integer is the best)
if(!is_int($nbr_fois)) { //if not integer, transform into integer with intval()
$nbr_fois = intval($nbr_fois);
}
if(is_scalar($str) && $nbr_fois > 0 && $nbr_fois < 40) {
$code = '$str';
for($i=0; $i<$nbr_fois; $i++) {
$code = 'md5('.$code.')';
}
eval('$hash = '.$code.';');
return $hash;
}
else {
return false;
}
}
?>