I checked the passwords for the users against the DB.
What is faster, the MySQL MD5 function
... pwd = MD5('.$pwd.')
OR the PHP MD5 function
... pwd = '.md5($pwd).'
What is the right way between the two options?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your application is only calcullating md5 when someone registers on your site, or is logging in, own many calls to md5 will you do per hour ? Couple of hundreds ? If so, I don’t think the really small difference between PHP and MySQL will be significant at all.
The question should be more like “where do I put the fact that password are stored using md5” than “what makes me win almost nothing”.
And, as a sidenote, another question could be : where can you afford to spend resources for that kind of calculations ? If you have 10 PHP servers and one DB server already under heavy load, you get your answer 😉
But, just for fun :
And in PHP :
gives :
But you probably won’t be calculating a million md5 like this, will you ?
(And this has nothing to do with preventing SQL injections : just escape/quote your data ! always ! or use prepared statements)