What's faster/better to use: the MySQL or PHP md5 function? -


I have checked the password for users against DB.

What is faster, MySQL MD5 function

  ... pwd = MD5 ('. $ Pwd.')  < / Pre> 

or PHP MD5 function

  ... pwd = '.md5 ($ pwd).'  

What is the correct way between the two options?

If your application is only reducing MD5, when someone registers your site, Or entering, you can do many calls on MD5 itself? Couple of hundreds? If so, then I do not think that really small difference between PHP and MySQL will be important at all.

The question should be more "Where do I say that the password is stored in comparison to" MD5 "compared to" winning almost nothing. "

And, one In the form of sidenote, another question may be: Where can you spend to spend resources to calculate that kind? If you have 10 PHP server and a DB server which is already heavy load , Then you get your answer; -)

But, for fun A:

  mysql> Select benchmark (1000000, MD5 ('test')); + ------------------- -------------- + | Benchmark (1000000, MD5 ('test')) | + -------------------- ------------- + | 0 | + -------------------------------- - + 1 line set (2.24 seconds)  

and in PHP:

  $ first = microtom (true); for ($ i = 0; $ I & lt; 1000000; $ i ++) {$ a = MD5 ('test');} $ = after microtom (true); echo ($ later- $ first) "\ n";  

returns:

  $ php ~ / developpement / tests / temp / temp.php 3.3341760635376  

but you might Like a million MD5 Will not count, do you?

(And there is nothing to stop it from stopping the SQL injection: Just avoid / quote your data! Always! Or use ready statement)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -