How to – password hashing in cakephp

November 25, 2007 at 6:44 am | In cakephp | Leave a Comment
Tags: , ,

How do you do password hashing in cakephp ?

The answer is really simple, use the Security class provided by cakephp.

Example usage -

In your controller, do the following
$this->data['User']['password'] = Security::hash($this->data['User']['password']);

where ‘User’ is the model and ‘password’ is the attribute that is used to capture the password entered by the user.

By default, Security::hash takes the type sha1.

And if you want to validate or check the password entered by the user against the hashed password stored in db, use the hash method and perform the check.

No Comments Yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.