3v4l.org

run code in 300+ PHP versions simultaneously
<?php class EAHashor { //initialise the class function __construct() { } function eaEncode($string){ $a = "67452301"; $b = "EFCDAB89"; $c = "98BADCFE"; $d = "10325476"; $words = $this->init($string); for($i = 0; $i <= count($words)/16-1; $i++){ $A = $a; $B = $b; $C = $c; $D = $d; /* ROUND 1 */ $this->FF ($A, $B, $C, $D, $words[0 + ($i * 16)], 7, "d76aa478"); $this->FF ($D, $A, $B, $C, $words[1 + ($i * 16)], 12, "e8c7b756"); $this->FF ($C, $D, $A, $B, $words[2 + ($i * 16)], 17, "242070db"); $this->FF ($B, $C, $D, $A, $words[3 + ($i * 16)], 22, "c1bdceee"); $this->FF ($A, $B, $C, $D, $words[4 + ($i * 16)], 7, "f57c0faf"); $this->FF ($D, $A, $B, $C, $words[5 + ($i * 16)], 12, "4787c62a"); $this->FF ($C, $D, $A, $B, $words[6 + ($i * 16)], 17, "a8304613"); $this->FF ($B, $C, $D, $A, $words[7 + ($i * 16)], 22, "fd469501"); $this->FF ($A, $B, $C, $D, $words[8 + ($i * 16)], 7, "698098d8"); $this->FF ($D, $A, $B, $C, $words[9 + ($i * 16)], 12, "8b44f7af"); $this->FF ($C, $D, $A, $B, $words[10 + ($i * 16)], 17, "ffff5bb1"); $this->FF ($B, $C, $D, $A, $words[11 + ($i * 16)], 22, "895cd7be"); $this->FF ($A, $B, $C, $D, $words[12 + ($i * 16)], 7, "6b901122"); $this->FF ($D, $A, $B, $C, $words[13 + ($i * 16)], 12, "fd987193"); $this->FF ($C, $D, $A, $B, $words[14 + ($i * 16)], 17, "a679438e"); $this->FF ($B, $C, $D, $A, $words[15 + ($i * 16)], 22, "49b40821"); /* ROUND 2 */ $this->GG ($A, $B, $C, $D, $words[1 + ($i * 16)], 5, "f61e2562"); $this->GG ($D, $A, $B, $C, $words[6 + ($i * 16)], 9, "c040b340"); $this->GG ($C, $D, $A, $B, $words[11 + ($i * 16)], 14, "265e5a51"); $this->GG ($B, $C, $D, $A, $words[0 + ($i * 16)], 20, "e9b6c7aa"); $this->GG ($A, $B, $C, $D, $words[5 + ($i * 16)], 5, "d62f105d"); $this->GG ($D, $A, $B, $C, $words[10 + ($i * 16)], 9, "02441453"); $this->GG ($C, $D, $A, $B, $words[15 + ($i * 16)], 14, "d8a1e681"); $this->GG ($B, $C, $D, $A, $words[4 + ($i * 16)], 20, "e7d3fbc8"); $this->GG ($A, $B, $C, $D, $words[9 + ($i * 16)], 5, "21e1cde6"); $this->GG ($D, $A, $B, $C, $words[14 + ($i * 16)], 9, "c33707d6"); $this->GG ($C, $D, $A, $B, $words[3 + ($i * 16)], 14, "f4d50d87"); $this->GG ($B, $C, $D, $A, $words[8 + ($i * 16)], 20, "455a14ed"); $this->GG ($A, $B, $C, $D, $words[13 + ($i * 16)], 5, "a9e3e905"); $this->GG ($D, $A, $B, $C, $words[2 + ($i * 16)], 9, "fcefa3f8"); $this->GG ($C, $D, $A, $B, $words[7 + ($i * 16)], 14, "676f02d9"); $this->GG ($B, $C, $D, $A, $words[12 + ($i * 16)], 20, "8d2a4c8a"); /* ROUND 3 */ $this->HH ($A, $B, $C, $D, $words[5 + ($i * 16)], 4, "fffa3942"); $this->HH ($D, $A, $B, $C, $words[8 + ($i * 16)], 11, "8771f681"); //HH ($C, $D, $A, $B, $words[11 + ($i * 16)], 16, "6d9d6122"); //EA change to use 14 rather than 16 as seen in the commented line $this->HH ($C, $D, $A, $B, $words[11 + ($i * 16)], 14, "6d9d6122"); $this->HH ($B, $C, $D, $A, $words[14 + ($i * 16)], 23, "fde5380c"); $this->HH ($A, $B, $C, $D, $words[1 + ($i * 16)], 4, "a4beea44"); $this->HH ($D, $A, $B, $C, $words[4 + ($i * 16)], 11, "4bdecfa9"); $this->HH ($C, $D, $A, $B, $words[7 + ($i * 16)], 16, "f6bb4b60"); $this->HH ($B, $C, $D, $A, $words[10 + ($i * 16)], 23, "bebfbc70"); $this->HH ($A, $B, $C, $D, $words[13 + ($i * 16)], 4, "289b7ec6"); $this->HH ($D, $A, $B, $C, $words[0 + ($i * 16)], 11, "eaa127fa"); $this->HH ($C, $D, $A, $B, $words[3 + ($i * 16)], 16, "d4ef3085"); $this->HH ($B, $C, $D, $A, $words[6 + ($i * 16)], 23, "04881d05"); $this->HH ($A, $B, $C, $D, $words[9 + ($i * 16)], 4, "d9d4d039"); $this->HH ($D, $A, $B, $C, $words[12 + ($i * 16)], 11, "e6db99e5"); $this->HH ($C, $D, $A, $B, $words[15 + ($i * 16)], 16, "1fa27cf8"); $this->HH ($B, $C, $D, $A, $words[2 + ($i * 16)], 23, "c4ac5665"); /* ROUND 4 */ $this->II ($A, $B, $C, $D, $words[0 + ($i * 16)], 6, "f4292244"); $this->II ($D, $A, $B, $C, $words[7 + ($i * 16)], 10, "432aff97"); $this->II ($C, $D, $A, $B, $words[14 + ($i * 16)], 15, "ab9423a7"); $this->II ($B, $C, $D, $A, $words[5 + ($i * 16)], 21, "fc93a039"); $this->II ($A, $B, $C, $D, $words[12 + ($i * 16)], 6, "655b59c3"); $this->II ($D, $A, $B, $C, $words[3 + ($i * 16)], 10, "8f0ccc92"); $this->II ($C, $D, $A, $B, $words[10 + ($i * 16)], 15, "ffeff47d"); $this->II ($B, $C, $D, $A, $words[1 + ($i * 16)], 21, "85845dd1"); $this->II ($A, $B, $C, $D, $words[8 + ($i * 16)], 6, "6fa87e4f"); $this->II ($D, $A, $B, $C, $words[15 + ($i * 16)], 10, "fe2ce6e0"); $this->II ($C, $D, $A, $B, $words[6 + ($i * 16)], 15, "a3014314"); $this->II ($B, $C, $D, $A, $words[13 + ($i * 16)], 21, "4e0811a1"); $this->II ($A, $B, $C, $D, $words[4 + ($i * 16)], 6, "f7537e82"); $this->II ($D, $A, $B, $C, $words[11 + ($i * 16)], 10, "bd3af235"); $this->II ($C, $D, $A, $B, $words[2 + ($i * 16)], 15, "2ad7d2bb"); $this->II ($B, $C, $D, $A, $words[9 + ($i * 16)], 21, "eb86d391"); //EA change to use this last line twice $this->II ($B, $C, $D, $A, $words[9 + ($i * 16)], 21, "eb86d391"); $this->addVars($a, $b, $c, $d, $A, $B, $C, $D); } $MD5 = ''; foreach (array($a, $b, $c, $d) as $x) { $MD5 .= implode('', array_reverse(str_split($this->leftpad($x, 8), 2))); } return $MD5; } /* General functions */ function hexbin($str){ $hexbinmap = array( "0" => "0000", "1" => "0001", "2" => "0010", "3" => "0011" , "4" => "0100" , "5" => "0101" , "6" => "0110" , "7" => "0111" , "8" => "1000" , "9" => "1001" , "A" => "1010" , "a" => "1010" , "B" => "1011" , "b" => "1011" , "C" => "1100" , "c" => "1100" , "D" => "1101" , "d" => "1101" , "E" => "1110" , "e" => "1110" , "F" => "1111" , "f" => "1111"); $bin = ""; for ($i = 0; $i < strlen($str); $i++){ $bin .= $hexbinmap[$str[$i]]; } $bin = ltrim($bin, '0'); // echo "Original: ".$str." New: ".$bin."<br />"; return $bin; } function strhex($str){ $hex = ""; for ($i = 0; $i < strlen($str); $i++){ $hex = $hex.$this->leftpad(dechex(ord($str[$i])), 2); } return $hex; } /* MD5-specific functions */ function init($string){ $len = strlen($string) * 8; $hex = $this->strhex($string); // convert ascii string to hex $bin = $this->leftpad($this->hexbin($hex), $len); // convert hex string to bin $padded = $this->pad($bin); $padded = $this->pad($padded, 1, $len); $block = str_split($padded, 32); foreach ($block as &$b) { $b = implode('', array_reverse(str_split($b, 8))); } return $block; } function pad($bin, $type=0, $len = 0){ if($type == 0){ $bin = $bin."1"; $buff = strlen($bin) % 512; if($buff != 448){ while(strlen($bin) % 512 != 448){ $bin = $bin."0"; } } } // append length (b) of string to latter 64 bits elseif($type == 1){ $bLen = $this->leftpad(decbin($len), 64); $bin .= implode('', array_reverse(str_split($bLen, 8))); } return $bin; } /* MD5 base functions */ function F($X, $Y, $Z){ $X = hexdec($X); $Y = hexdec($Y); $Z = hexdec($Z); $calc = (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z return $calc; } function G($X, $Y, $Z){ $X = hexdec($X); $Y = hexdec($Y); $Z = hexdec($Z); $calc = (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z return $calc; } function H($X, $Y, $Z){ $X = hexdec($X); $Y = hexdec($Y); $Z = hexdec($Z); $calc = ($X ^ $Y ^ $Z); // X XOR Y XOR Z return $calc; } function I($X, $Y, $Z){ $X = hexdec($X); $Y = hexdec($Y); $Z = hexdec($Z); $calc = ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z) return $calc; } /* MD5 round functions */ /* $A - hex, $B - hex, $C - hex, $D - hex (F - dec) $M - binary $s - decimal $t - hex */ function FF(&$A, $B, $C, $D, $M, $s, $t){ $A = hexdec($A); $t = hexdec($t); $M = bindec($M); $A = ($A + $this->F($B, $C, $D) + $M + $t) & 0xffffffff; //decimal $A = $this->rotate($A, $s); $A = dechex((hexdec($B) + hexdec($A)) & 0xffffffff); } function GG(&$A, $B, $C, $D, $M, $s, $t){ $A = hexdec($A); $t = hexdec($t); $M = bindec($M); $A = ($A + $this->G($B, $C, $D) + $M + $t) & 0xffffffff; //decimal $A = $this->rotate($A, $s); $A = dechex((hexdec($B) + hexdec($A)) & 0xffffffff); } function HH(&$A, $B, $C, $D, $M, $s, $t){ $A = hexdec($A); $t = hexdec($t); $M = bindec($M); $A = ($A + $this->H($B, $C, $D) + $M + $t) & 0xffffffff; //decimal $A = $this->rotate($A, $s); $A = dechex((hexdec($B) + hexdec($A)) & 0xffffffff); } function II(&$A, $B, $C, $D, $M, $s, $t){ $A = hexdec($A); $t = hexdec($t); $M = bindec($M); $A = ($A + $this->I($B, $C, $D) + $M + $t) & 0xffffffff; //decimal $A = $this->rotate($A, $s); $A = dechex((hexdec($B) + hexdec($A)) & 0xffffffff); } // shift function rotate ($decimal, $bits) { //returns hex return dechex((($decimal << $bits) | ($decimal >> (32 - $bits))) & 0xffffffff); } function addVars(&$a, &$b, &$c, &$d, $A, $B, $C, $D){ $A = hexdec($A); $B = hexdec($B); $C = hexdec($C); $D = hexdec($D); $aa = hexdec($a); $bb = hexdec($b); $cc = hexdec($c); $dd = hexdec($d); $aa = ($aa + $A) & 0xffffffff; $bb = ($bb + $B) & 0xffffffff; $cc = ($cc + $C) & 0xffffffff; $dd = ($dd + $D) & 0xffffffff; $a = dechex($aa); $b = dechex($bb); $c = dechex($cc); $d = dechex($dd); } function leftpad($needs_padding, $alignment) { if (strlen($needs_padding) % $alignment) { $pad_amount = $alignment - strlen($needs_padding) % $alignment; $left_pad = implode('', array_fill(0, $pad_amount, '0')); $needs_padding = $left_pad . $needs_padding; } return $needs_padding; } } $eahashor = new EAHashor(); $hash = $eahashor->eaEncode('test'); echo $hash;

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.20.0150.00618.08
8.4.10.0160.00617.62
8.3.150.0080.00817.66
8.3.140.0060.00316.54
8.3.130.0080.00018.50
8.3.120.0000.00920.65
8.3.110.0070.00416.87
8.3.100.0070.00324.06
8.3.90.0130.00626.77
8.3.80.0100.00016.75
8.3.70.0100.01016.75
8.3.60.0110.00418.43
8.3.50.0070.00821.99
8.3.40.0090.00619.21
8.3.30.0090.00619.07
8.3.20.0040.00419.13
8.3.10.0060.00320.97
8.3.00.0040.00423.70
8.2.270.0160.00316.95
8.2.260.0030.00516.91
8.2.250.0000.01016.86
8.2.240.0040.00419.04
8.2.230.0100.01020.94
8.2.220.0070.00437.54
8.2.210.0040.00426.77
8.2.200.0070.00316.75
8.2.190.0060.00916.63
8.2.180.0110.00718.29
8.2.170.0140.00722.96
8.2.160.0110.00320.60
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0030.00526.16
8.2.120.0000.00819.60
8.2.110.0030.00720.71
8.2.100.0060.00618.07
8.2.90.0030.00619.59
8.2.80.0050.00319.34
8.2.70.0060.00317.75
8.2.60.0030.00518.30
8.2.50.0090.00018.07
8.2.40.0080.00019.83
8.2.30.0070.00019.64
8.2.20.0000.00917.95
8.2.10.0000.00817.95
8.2.00.0030.00618.06
8.1.310.0000.00918.62
8.1.300.0090.00016.40
8.1.290.0060.00330.84
8.1.280.0070.00725.92
8.1.270.0070.00322.24
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0090.00022.59
8.1.230.0040.00721.14
8.1.220.0030.00518.77
8.1.210.0030.00619.19
8.1.200.0060.00317.60
8.1.190.0030.00617.43
8.1.180.0000.00918.10
8.1.170.0040.00418.78
8.1.160.0040.00419.12
8.1.150.0030.00518.77
8.1.140.0000.00817.67
8.1.130.0000.00718.12
8.1.120.0040.00417.63
8.1.110.0030.00517.74
8.1.100.0030.00617.72
8.1.90.0030.00517.59
8.1.80.0040.00417.66
8.1.70.0000.00817.58
8.1.60.0090.00017.80
8.1.50.0050.00317.63
8.1.40.0050.00317.70
8.1.30.0060.00317.91
8.1.20.0030.00617.91
8.1.10.0000.00917.80
8.1.00.0030.00617.81
8.0.300.0050.00320.09
8.0.290.0080.00017.43
8.0.280.0080.00018.73
8.0.270.0040.00417.18
8.0.260.0070.00017.18
8.0.250.0060.00317.15
8.0.240.0040.00417.14
8.0.230.0040.00417.27
8.0.220.0040.00417.29
8.0.210.0040.00417.21
8.0.200.0070.00017.14
8.0.190.0000.00717.26
8.0.180.0000.00717.24
8.0.170.0000.00817.18
8.0.160.0080.00017.17
8.0.150.0030.00617.06
8.0.140.0040.00417.20
8.0.130.0060.00013.73
8.0.120.0030.00617.23
8.0.110.0000.00817.15
8.0.100.0040.00417.00
8.0.90.0050.00317.09
8.0.80.0130.00317.10
8.0.70.0000.00817.14
8.0.60.0000.00816.98
8.0.50.0000.00917.07
8.0.30.0120.00817.50
8.0.20.0060.01417.49
8.0.10.0060.00317.24
8.0.00.0110.01116.88
7.4.330.0030.00315.12
7.4.320.0040.00416.79
7.4.300.0040.00416.84
7.4.290.0040.00416.84
7.4.280.0070.00316.86
7.4.270.0040.00416.62
7.4.260.0030.00313.64
7.4.250.0000.00716.64
7.4.240.0040.00416.78
7.4.230.0000.00816.59
7.4.220.0070.01816.68
7.4.210.0070.00916.77
7.4.200.0040.00416.66
7.4.190.0050.00316.87
7.4.160.0060.01016.82
7.4.150.0160.00317.40
7.4.140.0080.01117.86
7.4.130.0090.01316.70
7.4.120.0140.00616.70
7.4.110.0100.00716.68
7.4.100.0120.00616.88
7.4.90.0110.00716.70
7.4.80.0090.01519.39
7.4.70.0100.00716.84
7.4.60.0100.01116.79
7.4.50.0030.00616.64
7.4.40.0100.00622.77
7.4.30.0140.01016.80
7.4.00.0040.01115.06
7.3.330.0030.00313.57
7.3.320.0000.00713.47
7.3.310.0050.00216.60
7.3.300.0040.00416.57
7.3.290.0070.01016.59
7.3.280.0110.00916.55
7.3.270.0090.00917.40
7.3.260.0120.00818.24
7.3.250.0040.01416.67
7.3.240.0120.00616.77
7.3.230.0090.00916.82
7.3.210.0030.01516.91
7.3.200.0130.00619.39
7.3.190.0130.01316.64
7.3.180.0080.00816.61
7.3.170.0060.01016.75
7.3.160.0100.00716.66
7.3.120.0060.01015.25
7.2.330.0110.00816.98
7.2.320.0150.00617.18
7.2.310.0150.00617.13
7.2.300.0070.01316.71
7.2.290.0070.01016.86
7.2.00.0070.01019.20
7.1.100.0090.00618.00
7.1.70.0100.00317.14
7.1.60.0030.00917.21
7.1.50.0030.01816.70
7.1.00.0030.03322.32
7.0.200.0150.00316.79
7.0.140.0000.07721.97
7.0.100.0130.06320.20
7.0.90.0400.08020.22
7.0.80.0070.08320.25
7.0.70.0030.08720.12
7.0.60.0030.09020.17
7.0.50.0100.07720.63
7.0.40.0030.07720.09
7.0.30.0100.08320.10
7.0.20.0100.08720.15
7.0.10.0030.08720.14
7.0.00.0070.08320.05
5.6.280.0100.07021.25
5.6.250.0070.07020.78
5.6.240.0030.06320.84
5.6.230.0200.06320.82
5.6.220.0030.05720.73
5.6.210.0000.06320.76
5.6.200.0070.04721.18
5.6.190.0100.07721.20
5.6.180.0030.08321.20
5.6.170.0030.06721.25
5.6.160.0100.06721.05
5.6.150.0100.08021.21
5.6.140.0000.06321.04
5.6.130.0070.06021.22
5.6.120.0100.04721.19
5.6.110.0100.08321.04
5.6.100.0100.08721.06
5.6.90.0070.04721.23
5.6.80.0100.07320.54
5.6.70.0070.04320.52
5.6.60.0030.08020.50
5.6.50.0000.07720.57
5.6.40.0070.06720.55
5.6.30.0100.08020.55
5.6.20.0030.08020.55
5.6.10.0100.06020.55
5.6.00.0030.05320.41
5.5.380.0100.07020.59
5.5.370.0170.07320.57
5.5.360.0000.04720.46
5.5.350.0100.07320.45
5.5.340.0070.08321.02
5.5.330.0070.08320.96
5.5.320.0030.06321.04
5.5.310.0130.08020.91
5.5.300.0070.06020.98
5.5.290.0170.05021.00
5.5.280.0130.07720.88
5.5.270.0130.06720.99
5.5.260.0030.07720.90
5.5.250.0070.07320.72
5.5.240.0070.07720.26
5.5.230.0030.08020.36
5.5.220.0070.08720.29
5.5.210.0100.05020.37
5.5.200.0100.07720.27
5.5.190.0130.07320.23
5.5.180.0130.07720.21
5.5.160.0070.08020.38
5.5.150.0070.07720.30
5.5.140.0130.06720.38
5.5.130.0170.07020.30
5.5.120.0170.07320.34
5.5.110.0170.06320.26
5.5.100.0130.06720.20
5.5.90.0100.07320.27
5.5.80.0170.07720.19
5.5.70.0070.05720.16
5.5.60.0130.04720.16
5.5.50.0070.07020.28
5.5.40.0100.06720.21
5.5.30.0100.06720.21
5.5.20.0070.07720.27
5.5.10.0070.08020.09
5.5.00.0170.07720.23
5.4.450.0070.07719.28
5.4.440.0130.07719.46
5.4.430.0070.07719.41
5.4.420.0070.08019.45
5.4.410.0030.04319.11
5.4.400.0000.08719.23
5.4.390.0000.05019.20
5.4.380.0170.06319.17
5.4.370.0100.04719.08
5.4.360.0130.07319.08
5.4.350.0130.05319.09
5.4.340.0130.07018.91
5.4.320.0100.07318.96
5.4.310.0070.08319.14
5.4.300.0130.06719.05
5.4.290.0000.07719.26
5.4.280.0070.06719.16
5.4.270.0170.06319.16
5.4.260.0300.06019.11
5.4.250.0170.06319.12
5.4.240.0030.08019.12
5.4.230.0070.07718.93
5.4.220.0000.04719.09
5.4.210.0030.07718.89
5.4.200.0130.06019.15
5.4.190.0070.06019.11
5.4.180.0070.07719.00
5.4.170.0070.07318.88
5.4.160.0130.06019.25
5.4.150.0070.07018.89
5.4.140.0070.07316.52
5.4.130.0100.07316.44
5.4.120.0070.07716.44
5.4.110.0070.06716.43
5.4.100.0100.06716.50
5.4.90.0100.07016.47
5.4.80.0070.07016.41
5.4.70.0070.08016.43
5.4.60.0030.07716.45
5.4.50.0070.06316.45
5.4.40.0100.05716.45
5.4.30.0070.07016.57
5.4.20.0130.03316.53
5.4.10.0200.06316.49
5.4.00.0070.04015.95
5.3.290.0100.06314.99
5.3.280.0100.04014.89
5.3.270.0130.06314.95
5.3.260.0200.06714.77
5.3.250.0130.05714.79
5.3.240.0070.07314.83
5.3.230.0170.07014.83
5.3.220.0130.06314.83
5.3.210.0130.08014.78
5.3.200.0070.05314.77
5.3.190.0000.06314.77
5.3.180.0100.07014.70
5.3.170.0070.07014.73
5.3.160.0170.06314.80
5.3.150.0130.07014.83
5.3.140.0100.07014.88
5.3.130.0030.07314.73
5.3.120.0070.07014.74
5.3.110.0100.07314.70
5.3.100.0070.06714.33
5.3.90.0000.08014.18
5.3.80.0100.08314.21
5.3.70.0000.04314.22
5.3.60.0070.04314.11
5.3.50.0130.06314.26
5.3.40.0100.06714.17
5.3.30.0100.06314.24
5.3.20.0100.03713.96
5.3.10.0000.05313.83
5.3.00.0130.04313.83

preferences:
20.12 ms | 403 KiB | 5 Q