Tommy D’s Sexy Blog

TagLine Here

PHP Tip, using crypt()

Filed under: PHP Tips — Tommy D. at 8:24 am on Friday, June 24, 2005

If you need to keep track of users’ passwords for authentication – for example, if members have to login to your site – consider storing their password in an encrypted format instead of plaintext. This way, if your database somehow becomes compromised, the passwords for your user accounts are still somewhat safe.

One way to accomplish this is to run each newly created user’s password through PHP’s crypt() function and store the result:

$password = crypt($_POST[password]);

When the user attempts to login, crypt() the password they provide and compare it against the stored encrypted value. If they match, the password provided by the user was valid.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

 

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin