Jump to content

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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