Jump to content

Question about MD5?


pappakaka

Recommended Posts

I'm trying to secure my login system as much as possible from SQL injections and other attacks. I know that by using mysql_real_escape_string() you can prevent that and I'm using that on for example the username input, but I would like to know if you hash the password before you send it to the database with MD5, do you still need to use mysql_real_escape_string()?

 

A very quick and simple example:

 

<?php

$un = $_POST['username'];
$pass = $_POST['password'];
$pass = md5($pass);

mysql_query("SELECT * FROM users WHERE password='$pass' AND username='$un'");

?>

 

If someone wrote a possible SQL query in the password input, wouldn't that be rendered useless as the md5 will hash it before sending it and therefor "hide" it? Or is there any other reason you wouldn't want people to use sertain characters/symbols in their passwords?

Link to comment
Share on other sites

You don't need to escape special chars within an md5 hash because the special chars that are harmfull wont exist in the hashed data.

 

Ok thanks, so I can basically allow the users to use whatever characters they want in thier password? Or could that possibly be harmful any other way?

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.