encrypting password

i am about to make a 'log in' for my app and was wondering what is the best way to encrypt a password for my user that i will enter in my database ? I found many way on Google but don't know which is the best ..

Answers


I would go with a one way salted hash.

Using a SHA1 hash for example, you would have a way to store the password as a hash which cannot be reversed back to the original password. Then when the user enters his/her password you perform the same SHA1 hash on the password and compare that hash with what you have stored in the DB, if they match then the password is correct.

To further secure the hashing, you can add a salt, this is essentially a randomly generated value that you generate for each user then you create the account, and store the salt value in the user record. When you create the hash of the password, you first combine the password with the salt and hash this combined value. To authenticate the user you combine the entered password with the salt stored for the user, perform the hash on the combined value and compare.

By adding the salt to the mix, you ensure that the hash for passwords that happend to be the same have a different hash because the salted portion differs. So if two users have the same password "Password1234", the stored hash for the two will not be the same so it cannot be determined that two users have the same password.


Need Your Help

What is the most ridiculous pessimization you've seen?

performance optimization

We all know that premature optimization is the root of all evil because it leads to unreadable/unmaintainable code. Even worse is pessimization, when someone implements an "optimization" because t...

jQuery mobile show loader for custom loading process?

jquery css jquery-mobile setinterval jquery-mobile-loader

I'm building a web application that is rich in images and interactive elements. For these reasons I only want to display the page once all images are loaded:

Image not showing up in UITabBarItem

ios objective-c uiimage uitabbaritem

I am using UITabBar and UITabBarItem. I have an URL of an image. I set UITabBarItem's image to that image using URL. But image is not showing up. If I use any other image from my MacBook, it works....