[PHP-NOTES] note 130293 added to function.hash

[email protected] ("[email protected]")
Newsgroups php.notes
Message-ID <[email protected]>
Inspired by 3 examples ^_^

// PHP 8.2 laptop
// 1M loop/hash

<?php
$input = "Hello hash";
printf("%11s [%3s] [%5ss] %s\n\n",  "Algorithm", "Len", "Sec", "Hash");

foreach (hash_algos() as $algo) {

  $time = microtime(true);
  for($i=0; $i<1000000; $i++) {
    $hash = hash($algo, $input);
  }
  $time = sprintf("%.3f", microtime(true) - $time);

  $hash_size = strlen($hash);

  $hash = (strlen($hash) < 36) ? $hash : substr($hash, 0, 36)."..";

  printf("%11s [%3d] [%5ss] %s\n",  $algo, $hash_size, $time, $hash);
}
?>

Output

  Algorithm [Len] [  Secs] Hash

        md2 [ 32] [3.501s] 45a0e7057f11d1b2332728f82b40f655
        md4 [ 32] [0.284s] 2905fdb5702260d657b7f7a7228ed6e3
        md5 [ 32] [0.279s] 57abcff482bf87d93617c64415c74e3c
       sha1 [ 40] [0.398s] 7e47cbf98ee50c063c51aed8646aaea14831..
     sha224 [ 56] [0.745s] ea9afb35169aa21222fbed44758410e86ede..
     sha256 [ 64] [0.765s] 3acd9576d93aaea263970947260d369babf5..
     sha384 [ 96] [1.026s] 3e1da4c25e32a2a9279f68fe8a8de40a4fd1..
 sha512/224 [ 56] [1.028s] 1e0baf6f365b5c0635c55e3fb0f5398575f3..
 sha512/256 [ 64] [1.022s] 4c2d321520e75a2f2a56e35995884af66c52..
     sha512 [128] [1.056s] f5a3b55dd49cb667ec1a8c2c588e6c9d95d2..
   sha3-224 [ 56] [1.018s] 60288494d7d786c1d0bffe2712686369d6e2..
   sha3-256 [ 64] [0.990s] f375a6ff1a4dfa236a6da4c05f80042f1f06..
   sha3-384 [ 96] [0.957s] 29f3a317f84e47d5ea18cbad50ff9977fb68..
   sha3-512 [128] [0.983s] c2162dfa7fa579c634653a19c999528ec8f5..
  ripemd128 [ 32] [0.504s] bc376b563b64f273b9d75489c60dc2a5
  ripemd160 [ 40] [0.694s] c88f0e3558200622b882bda1a74b56774527..
  ripemd256 [ 64] [0.561s] 2687ac9e247e9261137b5ffdb132a960cce4..
  ripemd320 [ 80] [0.722s] 11290d93cfb813963045ccfde791f904ced9..
  whirlpool [128] [1.178s] cc6827169ea88605338894dd59cb2315c0d5..
 tiger128,3 [ 32] [0.334s] 416e8bf370fff46ae795bee92471e357
 tiger160,3 [ 40] [0.359s] 416e8bf370fff46ae795bee92471e357822e..
 tiger192,3 [ 48] [0.364s] 416e8bf370fff46ae795bee92471e357822e..
 tiger128,4 [ 32] [0.376s] a978ca0975e2d7836ac228e97f6e34c9
 tiger160,4 [ 40] [0.397s] a978ca0975e2d7836ac228e97f6e34c905ac..
 tiger192,4 [ 48] [0.407s] a978ca0975e2d7836ac228e97f6e34c905ac..
     snefru [ 64] [2.670s] 388a0c6129d708b5e2264f31c845656daa26..
  snefru256 [ 64] [2.694s] 388a0c6129d708b5e2264f31c845656daa26..
       gost [ 64] [2.190s] 8b88fcc7a42308e05cb09b94cdf10d8c596c..
gost-crypto [ 64] [2.169s] 817cb73c16701428e8049e9423ed2abf80ca..
    adler32 [  8] [0.137s] 140603b9
      crc32 [  8] [0.134s] 1b4a2ece
     crc32b [  8] [0.128s] 7bde5783
     crc32c [  8] [0.132s] 4e3a5aef
     fnv132 [  8] [0.126s] c96dda35
    fnv1a32 [  8] [0.134s] 2c9f09bd
     fnv164 [ 16] [0.140s] 9e080a27a09566d5
    fnv1a64 [ 16] [0.134s] b2a7d4903fe80c9d
      joaat [  8] [0.127s] 62b055ec
   murmur3a [  8] [0.128s] b5965160
   murmur3c [ 32] [0.189s] 0a79d58a4bdfc93845eec2ee552b7ece
   murmur3f [ 32] [0.186s] be7fd4e05150be5e224a2a153cd7ea32
      xxh32 [  8] [0.131s] 1dae6a2d
      xxh64 [ 16] [0.188s] c7ba1a21a12c56f9
       xxh3 [ 16] [0.192s] 10c7d24de409150f
     xxh128 [ 32] [0.201s] 04f032edb8bd4ef776fb60f5130fdaca
 haval128,3 [ 32] [0.938s] 65275c76151d7ef5854e014236b02eab
 haval160,3 [ 40] [0.926s] 1a20321f2114e03fe9a371d8c0a41db5d61b..
 haval192,3 [ 48] [0.954s] 179d01280481f39d04292a5ff4bc663e5553..
 haval224,3 [ 56] [0.969s] db3ecba4b34d724f8ea93776144867294f65..
 haval256,3 [ 64] [0.939s] 860772ed0543599eda2c0def6ebf403e048b..
 haval128,4 [ 32] [1.207s] 1c30864e7be7023092e53ea87284cbb3
 haval160,4 [ 40] [1.213s] 96abd8c3060c4d16e9e7f2dcafc69b65cfc9..
 haval192,4 [ 48] [1.243s] a53d398b248df085d9dd66138189cb949ab6..
 haval224,4 [ 56] [1.241s] 0ba043edb6ddd5391e36ae780fc29a26e9a6..
 haval256,4 [ 64] [1.262s] b2cb2100f0e01c1161f2e573cf5343495683..
 haval128,5 [ 32] [1.422s] 91da5c3061beaa457573c2037ee1cdd8
 haval160,5 [ 40] [1.431s] 8975bc70c6d08d6e778a452052715f8fc3d5..
 haval192,5 [ 48] [1.461s] f88a384109e443972fc0b3e66a787738d118..
 haval224,5 [ 56] [1.442s] cfd59c5d9ea8aef868648d9e68dc7d9c2fd1..
 haval256,5 [ 64] [1.456s] eaea51b4f3d2cba8442202b94dea96758b14..
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.84.18 (proxied: 172.56.120.173)
----
Manual Page -- https://php.net/manual/en/function.hash.php
Edit        -- https://main.php.net/note/edit/130293
Del: integrated  -- https://main.php.net/note/delete/130293/integrated
Del: useless     -- https://main.php.net/note/delete/130293/useless
Del: bad code    -- https://main.php.net/note/delete/130293/bad+code
Del: spam        -- https://main.php.net/note/delete/130293/spam
Del: non-english -- https://main.php.net/note/delete/130293/non-english
Del: in docs     -- https://main.php.net/note/delete/130293/in+docs
Del: other reasons-- https://main.php.net/note/delete/130293
Reject      -- https://main.php.net/note/reject/130293
Search      -- https://main.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.