User System and Passwords: I was looking through MD5 stuff, and I am wondering what is the normal/good practice for passwords. Right now, I think people super encrypt the passwords and store the hashes. If so, how does password checking work? I just have the input password go through the encryption process again and then check the hash with the stored one, correct?
This question may contradict the above, but should my salt ever be a randomly generated value? If so, when may it be useful?
Edit: Other than passwords, in a user system, what else should be encrypted as a good practice? Do they encrypt usernames or anything else?
2nd Edit: What is a one-way hash? I mean, technically, can I not reverse engineer my source code? Maybe this is a bad question because I do not know much about one-way hashing.
First you create a salt.
Note examples are written in PHP
Then salt the password
Store the
$hashand$saltin the database.When the user enters a password compare it to the hash
Never store passwords in a reversible format. Also I would advise against using MD5 as a hash.
Passwords aren’t encrypted, they are hashed. Picture a hash (very simplistic) as something that takes a number and multiplies it by ten. Say I want to hash the number
30. I would say30*10and get300as my “hash” for30. Note that you cannot derive30from300without knowing how the hash function works.That’s a very simplistic “hash” and if you know it always multiplies by ten then you could easily reverse it. Now take a look at the SHA1 hash function. It’s much more complicated. It can’t simply be reversed.
You will find that rarely is anything except the password hashed, and nothing is encrypted. The amount of overhead you would have with encrypting your database would be enormous.
I suppose you could apply a similar salt / hash pattern to the username, but then you have pitfalls. What if you want to use that username somewhere in your code? What if you want to check to make sure it’s unique to the table?
See above (or click here). A one way hash is just that. One way mapping.
A => Band nothing else.B !=> A, andAcan’t be anything exceptB.Someone mentioned the performance of an
XORoperation. While I feel performance is largely negligible I ran a quick test.Now run
Repeat as much as you want. The initial writeup uses the error log and I got the following results: