Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store Encrypted Username Hash in Database

I'm currently working on basic user authentication for an app I'm putting together, and I don't have much experience with security.

This said, I understand the practice (and necessity) of salting/storing a (salted) password hash in a database as a blob, as opposed to the password (encrypted or no). I've already implemented this.

Is there anything to be gained by salting/hashing a user name and storing the hash in the database, as opposed to the username in plain-text (or encrypted)? It strikes me this would make it quite a bit harder to determine which users may access the system using the database for authentication.

Since it's vital to make it difficult for someone to crack the password for a user account, wouldn't it also make sense to increase the difficulty for determining which users are viable?

Edit: it's possible some of the language I'm using isn't 100% correct: feel free to correct :-)

Edit2: I changed one of my first points to indicate salting hashes -- thanks everyone for pointing out that I missed this :-)

Edit3: Removed wording indicating I am encrypting/decrypting a password. I'm using salted hashes and am storing that in the DB -- thanks Scotty for pointing this out.

like image 875
bedwyr Avatar asked Mar 29 '09 05:03

bedwyr


1 Answers

If you salted & hashed the username, you'd leave yourself with a bit of a chicken & egg problem.

If you salted & hashed the username, how would you find it in the database? You'd need to look up the user's record to find the salt you used to hash the username...

like image 177
Michael Burr Avatar answered Oct 17 '22 09:10

Michael Burr