note 102408 deleted from function.md5 by joey
| From: | joey@php.net | Date: | Sun, 17 Jul 2011 08:37:56 +0000 |
| Subject: | note 102408 deleted from function.md5 by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181597@lists.php.net to get a copy of this message | ||
Note Submitter: Damian Micha Chudy
----
Very good encryption md5 + salt
<?php
// return array: salt and hash
function md5_salt($string) {
$chars = str_split('~`!@#$%^&*()[]{}-_\/|\'";:,.+=<>?');
$keys = array_rand($chars, 6);
foreach($keys as $key) {
$hash['salt'][] = $chars[$key];
}
$hash['salt'] = implode('', $hash['salt']);
$hash['salt'] = md5($hash['salt']);
$hash['string'] = md5($hash['salt'].$string.$hash['salt']);
return $hash;
}
?>