php - Is this hashing function overkill -
i began work on project , contains following function hash passwords :
function hash_password($password) { $account_id = $this->account_id; /* * cook randomness */ $password = str_rot13($password); $random_chars = "1%#)(d%6^".md5($password)."&h1%#)(d%6^&hb(d{}*&$#@$@fefwb".md5($password)."``~~+_+_o(ed##fvdfgrg:b>"; $salt = $account_id; $salt = ((int)$salt * 123456789) * 1000; $salt_len = strlen($salt); for($i=0; $i <= $salt_len; $i++) { $salt .= $random_chars[$i]; } $salt = str_repeat($salt, 3); return hash('sha256', base64_encode($password.$salt.$password), false); } *$account_id unique each user account.
my question : function more secure doing simple :
$salt = sha1($account_id); $hash = hash('sha256', base64_encode($password.$salt), false); cheers!
using account id salt not idea - if can steal hashed passwords, can account id's too. having more convoluted hash in code in instance therefore more secure, provided code protected. using known random string salt in code means have hack both data , code in order attack passwords - has better having attack database alone.
Comments
Post a Comment