The length and performance of various hash algorithms in PHP

Source: Internet
Author: User
Tags crc32 explode sha1

The hash results are as follows

<?PHP$data= "Hello World";foreach(Hash_algos () as $v) {        $r= Hash ($v,$data,false); printf("%-12s%3d%s\n",$v,strlen($r),$r);}?>MD232D9CCE882EE690A5C1CE70BEFF3A78C77MD432Aa010fbc1d14c795d86ef98c95479d17MD5325EB63BBBE01EEED093CB22BB8F5ACDC3SHA1402aae6c35c94fcfb415dbe95f408b9ce91ee846edsha224562f05477fc24bb4faefd86517156dafdecec45b8ad3cf2522a563582bsha25664b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9sha38496fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bdsha512128309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc554 2e93ae9cd76fripemd12832c52ac4d06245286b33953957be6c6f81ripemd1604098c615784ccb5fe5936fbc0cbe9dfdb408d92f0fripemd256640d375cf9d9ee95a3bb15f757c81e93bb0ad963edf69dc4d12264031814608e37ripemd320800e12fe7d075f8e319e07c106917eddb0135e9a10aefb50a8a07ccb0582ff1fa27b95ed5af57fd5c6whirlpool1288d8309ca6af848095bcabaf9a53b1b6ce7f594c1434fd6e5177e7e5c20e76cd30936d8606e7f36acbef8978fea008e6400a975d51abe6ba49231 78c7cf90c802tiger128, 3 324c8fbddae0b6f25832af45e7c62811bbtiger160, 3 404c8fbddae0b6f25832af45e7c62811bb64ec3e43tiger192, 3 484c8fbddae0b6f25832af45e7c62811bb64ec3e43691e9cc3tiger128, 4 3224465a3f6e4aa92d903ee535476591e9tiger160, 4 4024465a3f6e4aa92d903ee535476591e937f3a14dtiger192, 4 4824465a3f6e4aa92d903ee535476591e937f3a14d81c4c7b6snefru64902b49fa8b0828b44d8ac069111899bbfaf51d334485e4b28e90c93f63bb86ddsnefru25664902b49fa8b0828b44d8ac069111899bbfaf51d334485e4b28e90c93f63bb86ddgost641bb6ce69d2e895a78489c87a0712a2f40258d1fae3a4666c23f8f487bef0e22agost-crypto 64C5aa1455afe9f0c440eec3c96ccccb5c8495097572cc0f625278bd0da5ea5e07adler3281a0b045dCRC3287813f744crc32b80d4a1185fnv1328548da96ffnv1a328d58b3fa7fnv164167dcf62cdb1910e6ffnv1a6416779a65e7023cd2e7joaat83e4a5a57haval128, 3 32906c1df7cbe6d318f36ab172f95e89c0haval160, 3 406e733b21876e47c2168a122e23d86bdd69e50f95haval192, 3 48ec67a6a417953fdbf3496502004b6c21b270d5890dedd931haval224, 3 56766879d9ba1dc9e24a6040908a7ae813a47b08af5c5f3beebcacda48haval256, 3 6445492c6c8adab277759f4381420799431a037daf6d829b8b5c21104c10f61a92haval128, 4 32c97d46956b8e3e60acd2bb090c482c5ehaval160, 4 402cb8b12eb5a2561022010c2a2af8795e602fdef2haval192, 4 4839a281e4e492533b6dfea0af294149ccac771ab87204c9echaval224, 4 563d64d34aea48f5e649ed6147da5d29d31c762a937e9e21f4da1f3106haval256, 4 640359a526d77e271707c44d9b270e68a394f8486a459f0137ad5e1d02e44c5889haval128, 5 328332ad9f32e385d9acd421b63ee04cfchaval160, 5 40d33cf9052d55da9b0f506cb8849097939363e361haval192, 5 4867c3492878c8fc4819c8589231fcfe69b15b015c1ca48ac5haval224, 5 566bedeb6a8676e46413c020c8813c022486ca93353b8a0673fb577ba1haval256, 5 f5f6ffcfe39a65ac2c3989430340420341762a6624ebd69b9d08ec1dc4b9f167

The performance tests are as follows:

<?PHPDefine(' Testtime ', 1000000);$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);Print_r($time);?>Array([Fnv1a32]= 1.4528379546356[fnv164]= 1.4598390410767[Fnv1a64]= 1.4685498960724[fnv132]= 1.4695508840027[crc32b]= 1.480463955719[Adler32]= 1.481206043457[Joaat]= 1.4851269485474    [CRC32] = 1.508364085907[MD4]= 1.6973789288788    [MD5] = 1.7637529927979    [SHA1] = 1.932477017334[tiger128, 3] = 1.9683119142761[tiger160, 3] = 1.9759550503387[ripemd128]= 2.0003409449921[tiger192, 3] = 2.0107291056519[tiger128, 4] = 2.0609339611664[tiger160, 4] = 2.0614830404358[ripemd256]= 2.1055679496613[tiger192, 4] = 2.1089930283813[ripemd320]= 2.3564790057831[ripemd160]= 2.3820580299072[sha256]= 2.3944439311981[sha224]= 2.4205659084473[haval128, 3] = 2.5319820201874[haval224, 3] = 2.5319839861755[haval160, 3] = 2.5347460784149[haval192, 3] = 2.5500600071869[haval256, 3] = 2.580485933548[sha384]= 2.6736448852386[sha512]= 2.721533025589[haval224, 4] = 2.9019400155029[haval128, 4] = 2.9155439011078[haval256, 4] = 2.9168769813385[haval160, 4] = 2.9341630749512[haval192, 4] = 2.9478991126251[haval192, 5] = 3.1933639251862[haval256, 5] = 3.1942859609985[haval160, 5] = 3.1946619862823[Whirlpool]= 3.1954451004639[haval128, 5] = 3.2122300287323[haval224, 5] = 3.295264964798[GOST]= 4.6756690344391[Gost-crypto] = 4.6819899302826[Snefru]= 6.5784390528107[snefru256]= 6.6484970919647[MD2]= 11.291653894501)

The length and performance of various hash algorithms in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.