3v4l.org

run code in 300+ PHP versions simultaneously
<?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); $ivsize = mcrypt_get_iv_size(CIPHER, CIPHER_MODE); if ($ivsize === FALSE || $ivsize <= 0) { throw new CannotPerformOperationException(); } $iv = SecureRandom($ivsize); print urlsafe_b64encode($iv); 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; } // ORM = first L octets of T $orm = substr($t, 0, $length); if ($orm === FALSE) { throw new CannotPerformOperationException(); } return $orm; } ?>

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.3.40.0110.00418.70
8.3.30.0130.00318.85
8.3.20.0000.00820.25
8.3.10.0000.00823.71
8.3.00.0040.00419.38
8.2.170.0100.01022.96
8.2.160.0050.00820.23
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0000.00726.16
8.2.120.0030.00717.38
8.2.110.0100.00722.26
8.2.100.0060.00617.72
8.2.90.0040.00419.05
8.2.80.0040.00417.97
8.2.70.0030.00617.50
8.2.60.0040.00417.91
8.2.50.0060.00318.10
8.2.40.0080.00019.20
8.2.30.0050.00220.64
8.2.20.0000.00817.82
8.2.10.0070.00018.14
8.2.00.0040.00418.01
8.1.270.0060.00323.90
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00421.02
8.1.230.0060.00620.97
8.1.220.0000.00917.74
8.1.210.0030.00618.77
8.1.200.0030.00617.23
8.1.190.0080.00017.35
8.1.180.0000.00918.10
8.1.170.0000.00818.88
8.1.160.0000.00721.96
8.1.150.0090.00018.81
8.1.140.0040.00419.58
8.1.130.0030.00317.72
8.1.120.0070.00017.37
8.1.110.0060.00317.46
8.1.100.0080.00017.30
8.1.90.0030.00517.41
8.1.80.0090.00017.43
8.1.70.0000.00717.50
8.1.60.0030.00517.45
8.1.50.0030.00617.44
8.1.40.0090.00317.47
8.1.30.0060.00317.58
8.1.20.0000.00817.61
8.1.10.0040.00417.54
8.1.00.0050.00317.49
8.0.300.0000.00718.77
8.0.290.0000.00816.75
8.0.280.0050.00218.53
8.0.270.0000.00717.22
8.0.260.0030.00317.11
8.0.250.0000.00717.00
8.0.240.0050.00316.88
8.0.230.0030.00316.94
8.0.220.0070.00016.97
8.0.210.0070.00016.89
8.0.200.0000.00616.96
8.0.190.0030.00616.96
8.0.180.0040.00416.95
8.0.170.0040.00417.03
8.0.160.0000.00717.08
8.0.150.0030.00316.81
8.0.140.0030.00616.81
8.0.130.0030.00313.36
8.0.120.0040.00416.93
8.0.110.0000.00816.98
8.0.100.0000.00816.79
8.0.90.0000.00716.86
8.0.80.0040.01116.96
8.0.70.0030.00516.93
8.0.60.0000.00816.85
8.0.50.0000.00716.98
8.0.30.0060.01217.07
8.0.20.0080.01117.40
8.0.10.0080.00017.08
8.0.00.0050.01216.80
7.4.330.0030.00315.08
7.4.320.0000.00616.61
7.4.300.0000.00616.67
7.4.290.0060.00316.68
7.4.280.0040.00416.52
7.4.270.0040.00416.49
7.4.260.0070.00016.64
7.4.250.0080.00016.50
7.4.240.0020.00516.57
7.4.230.0050.00216.57
7.4.220.0100.01016.61
7.4.210.0070.00716.72
7.4.200.0070.00016.66
7.4.160.0090.00616.47
7.4.150.0110.00717.40
7.4.140.0060.01517.86
7.4.130.0110.01016.76
7.4.120.0080.00916.58
7.4.110.0110.01116.63
7.4.100.0150.00616.36
7.4.90.0140.00416.57
7.4.80.0120.01219.39
7.4.70.0120.00616.59
7.4.60.0060.00916.57
7.4.50.0030.00316.46
7.4.40.0070.01116.60
7.4.30.0110.00716.43
7.4.00.0030.01415.01
7.3.330.0050.00013.38
7.3.320.0050.00013.24
7.3.310.0050.00216.32
7.3.300.0030.00316.45
7.3.290.0040.00316.32
7.3.280.0050.01116.43
7.3.270.0090.00917.40
7.3.260.0100.00716.54
7.3.250.0140.00616.48
7.3.240.0050.01116.64
7.3.230.0150.00916.41
7.3.210.0100.00616.46
7.3.200.0180.00316.49
7.3.190.0070.01016.53
7.3.180.0130.00716.47
7.3.170.0070.01416.39
7.3.160.0070.01016.69
7.3.120.0030.00914.77
7.3.110.0070.01115.02
7.3.100.0060.00914.74
7.3.90.0110.00714.92
7.3.80.0030.00715.12
7.3.70.0030.01015.05
7.3.60.0040.01114.97
7.3.50.0070.00714.70
7.3.40.0030.01014.93
7.3.30.0060.00614.80
7.3.20.0070.01116.71
7.3.10.0050.01016.79
7.3.00.0090.00616.75
7.2.330.0060.01216.75
7.2.320.0060.01316.57
7.2.310.0100.00616.93
7.2.300.0070.01016.82
7.2.290.0080.00816.40
7.2.250.0140.00314.65
7.2.240.0130.00615.30
7.2.230.0070.00715.27
7.2.220.0070.00615.35
7.2.210.0060.00615.41
7.2.200.0040.01115.09
7.2.190.0130.00315.15
7.2.180.0030.01015.26
7.2.170.0000.01715.04
7.2.130.0030.00617.06
7.2.120.0030.01217.02
7.2.110.0000.01517.09
7.2.100.0000.01416.99
7.2.90.0070.00716.92
7.2.80.0060.00617.04
7.2.70.0060.00916.67
7.2.60.0090.00416.91
7.2.50.0060.00916.93
7.2.40.0030.01316.95
7.2.30.0030.01216.81
7.2.20.0040.01116.84
7.2.10.0150.00616.92
7.2.00.0100.00618.24
7.1.330.0100.00315.64
7.1.320.0080.00415.57
7.1.310.0000.01615.81
7.1.300.0110.00315.59
7.1.290.0040.00715.78
7.1.280.0090.00615.75
7.1.270.0110.00415.66
7.1.260.0120.00315.61
7.1.250.0110.00415.95
7.1.200.0060.00315.97
7.1.100.0030.01317.89
7.1.70.0000.00717.24
7.1.60.0120.01219.43
7.1.50.0060.01316.70
7.1.00.0000.08022.57
7.0.200.0290.00614.70
7.0.60.0070.04019.97
7.0.50.0000.09317.80
7.0.40.0070.09720.04
7.0.30.0070.08720.18
7.0.20.0230.07020.20
7.0.10.0030.07320.23
7.0.00.0030.04320.10
5.6.280.0000.06721.09
5.6.210.0100.06320.48
5.6.200.0100.08018.16
5.6.190.0170.07720.52
5.6.180.0270.07320.71
5.6.170.0300.07320.57
5.6.160.0100.06720.48
5.6.150.0070.08018.29
5.6.140.0130.07718.26
5.6.130.0030.05718.25
5.6.120.0100.08021.07
5.6.110.0200.07720.93
5.6.100.0100.07721.17
5.6.90.0100.08320.93
5.6.80.0030.08020.59
5.5.350.0270.07320.39
5.5.340.0000.07018.06
5.5.330.0100.08020.45
5.5.320.0030.08720.38
5.5.310.0300.03320.20
5.5.300.0100.07717.98
5.5.290.0170.05317.95
5.5.280.0070.04721.02
5.5.270.0070.06320.84
5.5.260.0030.09020.88
5.5.250.0070.07320.74
5.5.240.0070.08320.18

preferences:
39.18 ms | 400 KiB | 5 Q