Difference between #1 and #2 of
Secure password hashing with bCrypt

Revision #2 has been created by waitforit on Dec 20, 2011, 7:55:14 PM with the memo:

Added password check in UserIdentity component
« previous (#1) next (#3) »


Title unchanged

Secure password hashing with bCrypt

Category unchanged


Yii version unchanged

Tags unchanged

security, password, hash, hashing, bcrypt, login

Content changed

$enc = NEW bCrypt();
return $enc->hash($value);

#### UserIdentity - Modify password check to the following static method:
} else if (!bCrypt::verify($this->password, $user->password)) {
#### Discussion How does this work? By hooking into the User model's afterValidate() method we can drop in this code without any major changes to the UserIdentity or other components. What happens is that when your login form is submitted the inputs are validated (username, password). If they pass validation, the password value gets sent through the encrypt function and returned as a hash for database comparison. The only remaining work to do is to ensure that your password field in the database is large enough to hold the values. I recommend using char(60) as field type.
5 0
Viewed: 25 185 times
Version: 1.1
Category: How-tos
Written by: waitforit
Last updated by: Ivo Pereira
Created on: Dec 20, 2011
Last updated: 5 years ago
Update Article


View all history