No point in addslashes etc
If you use a script like this:
$user=md5($_POST['user']);
$pass=md5($_POST['pass']);
#sql="Select * from users where md5(user)='".$user."' and md5(pass)='".$pass." LIMIT 1';
It's pointless to use any other security measure maybe except overflow testing. Encoding the input into md5 prevents any malicious characters from sneaking in.
Am I right?
ynori7 wrote: Likely. Why don't you try it and see? That's the best way to find out. That I will. However, I am not as experienced at sql injection as some other people on here.
Also, another question:
Since this method cannot be used for storing forum posts (you want them not-md5 hashed), could you simply use hex encoding to store posts in a db? Or would it increase the volume of the db too much (5 to 6 times as much)?
MoshBat wrote: [quote]ranma wrote: That I will. However, I am not as experienced at sql injection as some other people on here.
Also, another question:
Since this method cannot be used for storing forum posts (you want them not-md5 hashed), could you simply use hex encoding to store posts in a db? Or would it increase the volume of the db too much (5 to 6 times as much)?
You're overcomplicating the most simple of things.
" or 1=1– ' or 1=1–
See, I can write those things, and the database it just fine. I wonder how that's done… Think![/quote]
I can do that easily, but some websites are immune to that but are vulnerable to others.
And my question stands. Could the md5 method be effectively used?
MoshBat wrote: Okay. I'll just mock up some code for you…
$pass = md5($_POST['pass']);
$qwerty = mysql_query("SELECT * FROM users WHERE user = '$user' AND pass = '$pass'");
//next bit.```
No point using mysql_real_escape_string AND addslashes, use one or the other (preferably mysql_real_escape_string)
ranma wrote: That's why I just use md5. Is it way more resource-intensive? Yes it is. The algoritm looks like this. Just use mysql_real_escape_string() and you'll be fine. I don't see any reason not to use the standard function(s) created to prevent SQL-injections.