Jump to content

Add MD5 hash to POST code


webguync

Recommended Posts

well since it is going into the database you might wanna just incase.

 

As already stated, there is no need to do so, and it can actually be problematic to escape data that will be hashed. Here's why:

 

include('db_conn.php');
$string = "This \string\ is Bob's.";
echo md5($string) . " Hash of: $string";
echo '<br>' . md5(mysqli_real_escape_string($dbc, $string)) . " Hash of: " . mysqli_real_escape_string($dbc, $string);

 

The above returns this result. Make note that the hashed values do not match because the escaped string is different from the original.

Hash:  58d026576a486ce984336c666a941e0a  $string: This \string\ is Bob's.
Hash:  ad29428d5e650e5fa47d03f8ff21222a     Escaped $string: This \\string\\ is Bob\'s.

Link to comment
Share on other sites

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.