Jump to content

MD5 and different hash values


extrovertive

Recommended Posts

I'm using MD5 to hash passwords stored in a database.

However, as I insert test entries using the same password, I see the same hash value. That means, if I know my password and if another user has the same hash value in the database, that person has the same database as me.

How do I make MD5 hashing value all different even if users enter the same password? How does adding a salt to MD5 in PHP work?
Link to comment
https://forums.phpfreaks.com/topic/17324-md5-and-different-hash-values/
Share on other sites

I honestly dont see the problem. It's entirely possible I have the same password as someone on these very forums, that doesn't instantly give me access to their account, because I dont know who if anyone has the same password as me to begin with.
Just a random string. In my example salt was:
$salt="dsjfwngngiu3w";

You can make it even more complex with things like:
$salt_a="jgweg";
$salt_b="439683nfg";
$hash=md5($salt_a.$password.$salt_b);

You just have to keep in mind that every time a user log's in you need to add those strings before and after the password inorder it to match the one in the database.

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.