note 76078 deleted from function.md5 by danbrown

From: Date: Mon, 18 Jul 2011 13:57:45 +0000
Subject: note 76078 deleted from function.md5 by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181641@lists.php.net to get a copy of this message
Note Submitter: AzuMao at gmail dot com ---- Here is a far more accurate test if you are not going to be doing it over and over. <?php $time=microtime(1); hash('md5', 'string'); echo (microtime(1)-$time)*10000,': hash/md5<br>'; $time=microtime(1); md5('string'); echo (microtime(1)-$time)*10000,': md5<br>'; $time=microtime(1); hash('sha1', 'string'); echo (microtime(1)-$time)*10000,': hash/sha1<br>'; $time=microtime(1); sha1('string'); echo (microtime(1)-$time)*10000,': sha1<br>'; ?> Outputs 0.11920928955078: hash/md5 0.090599060058594: md5 0.14066696166992: hash/sha1 0.050067901611328: sha1 Refresh it a few times and you will see that it is indeed consistant. sha1 is faster if you are not going to be using it over and over. I'm using this for etags in PHP and only need to use it once, so for me sha1 is faster. Note that these times are all times by 10000 so that it shows up as a real number instead of something like 1.1920928955078E-5: hash/md5 8.1062316894531E-6: md5 1.4066696166992E-5: hash/sha1 5.9604644775391E-6: sha1 (to negative powers)

« previous php.notes (#181641) next »