Home > Backend Development > PHP Tutorial > Speed ​​test comparison code for various encryption algorithms and Hash algorithms in PHP, hash speed test_PHP tutorial

Speed ​​test comparison code for various encryption algorithms and Hash algorithms in PHP, hash speed test_PHP tutorial

WBOY
Release: 2016-07-13 10:23:11
Original
1093 people have browsed it

Speed ​​test comparison code of various encryption algorithms and Hash algorithms in PHP, hash speed test

PHP’s Hash algorithm is relatively commonly used. The current MD5 is sometimes not safe, so other algorithms in Hash_algos() have to be used. A performance comparison is made below.

php code:

define('testtime', 50000);
$algos = hash_algos();
foreach($algos as $algo) {
	$st = microtime();
	for($i = 0; $i < testtime; $i++) {
		hash($algo, microtime().$i);
	}
	$et = microtime();
	list($ss, $si) = explode(' ', $st);
	list($es, $ei) = explode(' ', $et);
	$time[$algo] = $ei + $es - $si - $ss;
}
asort($time, SORT_NUMERIC);
echo "";
print_r($time);
Array
(
  [crc32b] => 0.14577506593323
  [crc32] => 0.14600901216125
  [adler32] => 0.14769597711182
  [md4] => 0.1584680151825
  [md5] => 0.15956400747681
  [salsa20] => 0.16176804933166
  [salsa10] => 0.16325911569214
  [tiger128,3] => 0.16543607070923
  [sha1] => 0.16547892630005
  [tiger160,3] => 0.16672711079407
  [tiger192,3] => 0.16793211837769
  [tiger128,4] => 0.16802901655579
  [sha224] => 0.16959108877563
  [tiger160,4] => 0.1713979150238
  [tiger192,4] => 0.1717759589386
  [sha256] => 0.17396298696899
  [ripemd256] => 0.17431005943298
  [ripemd128] => 0.17437094918823
  [ripemd320] => 0.17870710316467
  [haval160,3] => 0.18147005220032
  [haval256,3] => 0.18150104528809
  [haval224,3] => 0.18176211320496
  [sha512] => 0.18234492471313
  [haval192,3] => 0.18296506645203
  [ripemd160] => 0.18318411643982
  [haval128,3] => 0.18408892243958
  [sha384] => 0.18502903718567
  [haval128,4] => 0.18848111178589
  [haval256,4] => 0.18875202952576
  [haval160,4] => 0.1895639828186
  [haval224,4] => 0.19041207319641
  [haval192,4] => 0.19101205462646
  [whirlpool] => 0.19728892146301
  [haval256,5] => 0.19996902294922
  [haval160,5] => 0.20026498704529
  [haval192,5] => 0.20072503967285
  [haval128,5] => 0.20132308227539
  [haval224,5] => 0.2025869493103
  [gost] => 0.24892493852234
  [snefru256] => 0.28652299385071
  [snefru] => 0.29043891609192
  [md2] => 0.6300178873291
)
Copy after login

Some questions about PHP encryption algorithm

1. The encryption algorithm is MCRYPT_RIJNDAEL_128. As for whether it is the AES you mentioned, it is hard to say. I personally think it shouldn't be. After all, the two don't look much alike.

2. There is no flaw in the code, but all encryption may be broken. The exhaustive method is just a time-consuming problem.
3. IV is used to initialize the algorithm. It also needs to be kept confidential.

Use c language to implement symmetric encryption algorithm, asymmetric encryption algorithm and HASH algorithm. Can anyone provide an idea?

Baidu Zhaozhan

There are RSA algorithm, MD5 algorithm, and Wenig algorithm

These algorithms are very easy to find. There is an article about RSA in my space

Baidu search

These codes are inherently difficult to understand and involve a lot of mathematics

It is said that it took more than ten years for anyone to understand the source code of IBM's DES encryption.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/840765.htmlTechArticleSpeed ​​test comparison code for various encryption algorithms and Hash algorithms in PHP. Hash speed test PHP’s Hash algorithm is It is more commonly used. The current MD5 is sometimes not very safe, so you have to use Hash_al...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template