Hellow Reader's ,
In this Blog you can learn how to secure your password in DB with Blowfish password hasher. it is very difficult to hack. you can use blowfish hasher by following these steps.
First use below line in your User (Model)
App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
Then add this in model
public function beforeSave($options = array()) {
// hash the user's password before we save it
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash(
$this->data[$this->alias]['password']
);
}
// fallback to our parent
return parent::beforeSave($options);
}
It will hash your password before save record in Database
and for use blowfish hash password add this in auth component (AppController)
public $components = array('Session', 'Cookie',
'Auth' => array(
'authenticate' => array(
'Form' => array(
'passwordHasher' => 'Blowfish',
'userModel' => 'User',
'fields' => array(
'username' => 'username',
'password' => 'password'
)
)
)
),
);
Please feel free to comment.
0 Comment(s)