Yet Another Reason Not To Use Sha1 As A Password Hash
#1
Posted 05 December 2012 - 10:31 AM
Like MD5, SHA1 was never really intended to be used as a hash for passwords. Use SHA512, bcrypt, or any of the slower hashes that take multiple passes over a string. Use salt. Use phpass rather than rolling your own: http://www.openwall.com/phpass/

My rarely updated, incredibly rambing, questionably informative blog || Don't go to w3schools || Using 'global' is a sign of doing it wrong
#2
Posted 05 December 2012 - 10:37 AM
#3
Posted 05 December 2012 - 10:37 AM
public function encrypt($username, $password, $salt){
$config = Registry::get("config");
$pepper = $config->peppercode;
$password = md5($password);
$newpassword = sha1($username.$password);
$finalpassword = hash('sha512', $pepper.$newpassword.$salt);
return $finalpassword;
}
Kinda weird isnt it?
Edited by Hall of Famer, 05 December 2012 - 10:39 AM.
Welcome to the world of OOPHP! In a perfect script, everything is an object. You cannot be perfect, but you can approach as close as can.

#4
Posted 05 December 2012 - 08:31 PM
blowfish implementation
private function encrypt($string, $salt) {
if (strlen($salt) < 21)
trigger_error('Member#encrypt: Failed due to salt length less then 21.', E_USER_ERROR);
return crypt($string, '$2y$10$' . $salt . '$');
}
Edited by RobertP, 05 December 2012 - 08:31 PM.
#5
Posted 14 December 2012 - 06:14 PM
Just wondering though, are there any specific PHP security books you guys recommend?
#6
Posted 15 December 2012 - 03:00 AM
#7
Posted 15 December 2012 - 04:11 AM
Edited by Stefany93, 15 December 2012 - 04:12 AM.
"Never take counsel of your fears!" - Stonewall Jackson
My site - http://dyulgerova.info
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












