security - How do I implement salt into my login for passwords? -


I want to apply a salt to my login system, but it is a bit confusing how it should work. I can not understand the logic behind this I understand that MD5 is a single algorithm and all functions that I have found are all looking for hash together. If this is the case, how do I get my password back for comparison? My biggest question is how safe is it to secure a user's password through password? If a database was ever compromised, then there is a hash with salt in the database. Is not it that a hacker is needed?

I have found another post here, where another developer said:

"Make sure your salts and algorithms are stored different from databases < / Strong>

I would like to store salt in the database. Is this really a problem if I do?

I'm doing some help in understanding this I know how it works and also what best practice can be. Any help is greatly appreciated. It is.


EDIT: I want to thank everyone for your responses and thoughts, although I can now be more confused, it definitely will be a learning experience for me Thanks again people.

A hash function always returns the same value for the same input string Let's assume that my user (Alice) has the password hidden hashing th Using to the following hash

  5ebe2294ecd0e0f08eab7690d2a6ee69  

dictionary (a list of common words and passwords) or in different services The one who provides this service to you, the attacker can easily find that the secret word is secret when it sees in its dictionary that 5ebe2294ecd0e0f08eab7690d2a6ee69 = secret

The process of salt before the hushing makes it difficult to use the dictionary attack without knowing your salt, consider the following:

   

The resulting hash is now b58ad809eece17322de5024d79299f8a , but Alice's password is still secret . Now if Malory gets her hand on the salted hash, then it is likely that she will not get the answer in her dictionary. If he does this, he will be given a wrong answer.

Never store stable salt in your database preferably store it with the configuration of your application (the way the web should not be available).

If you are going to use a dynamic salt, you will need to use the database to make your salt use a non-empty column of existing valid data (secret encryption key The bluffish-encrypted string of the user name is usually cryptographically protected). Do not use a separate column for salt If you can not use an existing column, then add your salt to your hash in the same column. For example, use the first 32 letters for your 128-bit salt and then use the last 40 for your 160-bit hash. The following functions will generate such a hash:

  function cined_sha1 ($ string, $ seed_beat) {if (($ seed_beat% 8)! = 0) {new exception throw ('bits Should be 8 'divisible by); } $ Salt = ''; ($ I = 0; $ i & lt; $ seed_bits; $ i + = 8) {$ salt = Pack ('c', mt_rand ()); } $ Hexsalt = unpack ('h * hex', $ salt); $ Hexal ['hex'] Return Sha1 ($ salt. $ String); } Function comparison_seeded_sha1 ($ plain, $ hash) {$ sha1 = substr ($ hash, -40); $ Salt = pack ('h *', substr ($ hash, 0, -40)); $ Plain_hash = sha1 ($ salt. $ Plain); Return ($ plain_hash == $ sha1); }  

If an attacker comes into your database using SQL injection, then at least those who receive it will not be useful because it will not be able to access your application configuration. . If your server gets rooted, then this is a lot of games-no matter what you do.

Note: Other types of attacks are possible, so you use a more secure hashing algorithm, for example. Or, better than this, use it, which is designed with security in mind and is compatible with any PHP version on the back.

  is required ('PasswordHash.php'); $ PwdHasher = New Password Lost (8, FALSE); // $ hash that you will store in your database $ hash = $ pwdHasher-> HashPassword ($ password); // $ hash $ $ check = $ pwdHasher- & gt; $ Hash will be stored in your database for the checkpassword ($ password, $ hash); If ($ check) {echo 'password correct'; } And {echo 'wrong credentials'; }  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -