Jump to content

Encrypting passwords for database use and verifying it when logging in


scrubbicus

Recommended Posts

I was looking for a way to encrypt the password that's put into a database when a user signs up then whenever they're going to log back in I can decrypt it to check it against the password they entered.

 

I've been looking for a way I stumbled across md5 a lot but there were dozens of mixed opinions on whether it was one-way and your never getting back the original string or there is a way to decrypt it but no one was saying how.

 

Any help appreciated. Thanks.

Link to comment
Share on other sites

I've been looking for a way I stumbled across md5 a lot but there were dozens of mixed opinions on whether it was one-way and your never getting back the original string or there is a way to decrypt it but no one was saying how.

 

md5 != encryption. It's a hashing algorithm. As such, it cannot be decrypted and is one-way. You may be able to use reverse-lookup tables(aka rainbow tables)/and or brute force in order to find another string generating the same hash -- but you cannot guarantee to get the original back. There was a discussion here about this too. The thread's a few pages long though, so you might get bored.

 

In short, use MD5 + a salt to secure your passwords. Then, as Garethp says, you hash the inputted password (along with the same salt) and compare it against the original.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.