3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php const CIPHER = MCRYPT_RIJNDAEL_128; const KEY_BYTE_SIZE = 16; const CIPHER_MODE = 'cbc'; const HASH_FUNCTION = 'sha256'; const MAC_BYTE_SIZE = 32; const ENCRYPTION_INFO = 'PIPS|KeyForEncryption'; const AUTHENTICATION_INFO = 'PIPS|KeyForAuthentication'; $key = base64_decode('wdmd3XIhnOAelom4Y8yPbw=='); $ekey = HKDF(HASH_FUNCTION, $key, KEY_BYTE_SIZE, ENCRYPTION_INFO); print "$ekey\n"; print urlsafe_b64encode($ekey); function urlsafe_b64encode($string) { $data = base64_encode($string); $data = str_replace(array('+','/','='),array('-','_',''),$data); return $data; } function HKDF($hash, $ikm, $length, $info = '', $salt = NULL) { // Find the correct digest length as quickly as we can. $digest_length = MAC_BYTE_SIZE; if ($hash != HASH_FUNCTION) { $digest_length = strlen(hash_hmac($hash, '', '', true)); } // Sanity-check the desired output length. if (empty($length) || !is_int($length) || $length < 0 || $length > 255 * $digest_length) { return CannotPerformOperationException(); } // "if [salt] not provided, is set to a string of HashLen zeroes." if (is_null($salt)) { $salt = str_repeat("\x00", $digest_length); } // HKDF-Extract: // PRK = HMAC-Hash(salt, IKM) // The salt is the HMAC key. $prk = hash_hmac($hash, $ikm, $salt, true); // HKDF-Expand: // This check is useless, but it serves as a reminder to the spec. if (strlen($prk) < $digest_length) { throw new CannotPerformOperationException(); } // T(0) = '' $t = ''; $last_block = ''; for ($block_index = 1; strlen($t) < $length; $block_index++) { // T(i) = HMAC-Hash(PRK, T(i-1) | info | 0x??) $last_block = hash_hmac( $hash, $last_block . $info . chr($block_index), $prk, true ); // T = T(1) | T(2) | T(3) | ... | T(N) $t .= $last_block; } return $t; // ORM = first L octets of T $orm = substr($t, 0, $length); if ($orm === FALSE) { throw new CannotPerformOperationException(); } return $orm; } ?>
based on KRNWg

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0040.01117.07
7.2.00.0060.00819.47
7.1.200.0000.01415.79
7.1.100.0030.00918.23
7.1.70.0000.00917.22
7.1.60.0100.01419.43
7.1.50.0030.01717.13
7.1.00.0030.07322.57
7.0.200.0290.00914.50
7.0.60.0030.04020.12
7.0.50.0000.05317.76
7.0.40.0200.07320.41
7.0.30.0100.07720.11
7.0.20.0270.05320.23
7.0.10.0030.05020.05
7.0.00.0170.08020.05
5.6.210.0170.06720.54
5.6.200.0030.07318.21
5.6.190.0030.05320.34
5.6.180.0330.07720.62
5.6.170.0170.07720.51
5.6.160.0070.05020.54
5.6.150.0100.07318.16
5.6.140.0130.07318.13
5.6.130.0070.04718.15
5.6.120.0030.09021.00
5.6.110.0100.08721.15
5.6.100.0100.05020.88
5.6.90.0000.08021.12
5.6.80.0170.04020.33
5.5.350.0330.07720.46
5.5.340.0070.07718.08
5.5.330.0070.08020.56
5.5.320.0130.04020.38
5.5.310.0170.04720.27
5.5.300.0100.07317.98
5.5.290.0070.08318.05
5.5.280.0000.06020.91
5.5.270.0000.05020.79
5.5.260.0100.08020.78
5.5.250.0100.08020.63
5.5.240.0030.07020.17
5.4.450.0100.05719.47
5.4.440.0130.05319.50
5.4.430.0030.06019.57
5.4.420.0430.05719.54
5.4.410.0570.05319.20
5.4.400.0600.04719.32
5.4.390.0530.05719.25
5.4.380.0630.04718.98
5.4.370.0500.07019.32
5.4.360.0570.04719.29
5.4.350.0470.05719.10
5.4.340.0470.05718.98
5.4.320.0430.06019.14
5.4.310.0470.04719.14
5.4.300.0430.06019.27
5.4.290.0370.05719.05
5.4.280.0330.06019.21
5.4.270.0400.05319.11
5.4.260.0630.05318.84
5.4.250.0430.05319.19
5.4.240.0500.05318.97
5.4.230.0530.05018.88
5.4.220.0430.06019.05
5.4.210.0430.05719.21
5.4.200.0700.05319.11
5.4.190.0470.05719.31
5.4.180.0530.05719.12
5.4.170.0430.06018.83
5.4.160.0500.05019.01
5.4.150.0530.05319.22
5.4.140.0530.05016.59
5.4.130.0530.07016.39
5.4.120.0530.04716.44
5.4.110.0470.05316.63
5.4.100.0570.04316.58
5.4.90.0430.05316.57
5.4.80.0500.05016.55
5.4.70.0530.04316.29
5.4.60.0470.05016.58
5.4.50.0470.05316.61
5.4.40.0600.04316.50
5.4.30.0470.05016.23
5.4.20.0430.05316.64
5.4.10.0530.05316.59
5.4.00.0470.05015.84
5.3.290.0570.04714.65
5.3.280.0630.04014.70
5.3.270.0530.05014.63
5.3.260.0530.05014.68
5.3.250.0500.05014.52
5.3.240.0600.04014.85
5.3.230.0530.04714.67
5.3.220.0530.04714.63
5.3.210.0500.05314.57
5.3.200.0400.05314.64
5.3.190.0470.05714.63