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; } function SecureRandom($octets) { $random = mcrypt_create_iv($octets, MCRYPT_DEV_URANDOM); if ($random === FALSE) { throw new CannotPerformOperationException(); } else { return $random; } } ?>

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.00318.75
8.3.30.0040.01118.82
8.3.20.0080.00020.34
8.3.10.0080.00023.66
8.3.00.0030.00619.13
8.2.170.0040.01122.96
8.2.160.0100.00320.39
8.2.150.0040.00424.18
8.2.140.0050.00524.66
8.2.130.0070.00026.16
8.2.120.0060.00317.63
8.2.110.0040.00419.38
8.2.100.0040.00717.72
8.2.90.0080.00019.09
8.2.80.0040.00417.97
8.2.70.0060.00317.50
8.2.60.0060.00617.54
8.2.50.0040.00418.07
8.2.40.0060.00319.21
8.2.30.0040.00420.53
8.2.20.0000.00817.79
8.2.10.0040.00418.09
8.2.00.0040.00417.94
8.1.270.0040.00423.79
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00023.77
8.1.230.0110.00022.65
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0050.00516.88
8.1.180.0030.00618.10
8.1.170.0000.00718.87
8.1.160.0000.00821.92
8.1.150.0000.00818.84
8.1.140.0040.00419.54
8.1.130.0030.00317.67
8.1.120.0050.00217.42
8.1.110.0040.00417.30
8.1.100.0100.00017.35
8.1.90.0040.00417.43
8.1.80.0060.00317.38
8.1.70.0070.00017.47
8.1.60.0040.00417.56
8.1.50.0110.00017.56
8.1.40.0070.00317.32
8.1.30.0050.00317.45
8.1.20.0060.00317.61
8.1.10.0020.00517.51
8.1.00.0040.00417.36
8.0.300.0040.00418.77
8.0.290.0030.00616.75
8.0.280.0000.00718.38
8.0.270.0030.00517.19
8.0.260.0060.00017.25
8.0.250.0000.00816.86
8.0.240.0000.00817.03
8.0.230.0040.00417.00
8.0.220.0000.00716.99
8.0.210.0040.00416.99
8.0.200.0050.00317.04
8.0.190.0030.00516.92
8.0.180.0040.00416.93
8.0.170.0000.00716.86
8.0.160.0000.00717.03
8.0.150.0040.00416.77
8.0.140.0040.00716.77
8.0.130.0040.00413.41
8.0.120.0030.00616.93
8.0.110.0000.00817.04
8.0.100.0000.00716.88
8.0.90.0080.00016.98
8.0.80.0120.00916.96
8.0.70.0070.00016.89
8.0.60.0000.00716.86
8.0.50.0040.00416.86
8.0.30.0160.00317.04
8.0.20.0100.00917.40
8.0.10.0000.00717.11
8.0.00.0090.00716.84
7.4.330.0050.00015.10
7.4.320.0030.00316.64
7.4.300.0000.00616.56
7.4.290.0080.00016.41
7.4.280.0030.00616.44
7.4.270.0000.00716.56
7.4.260.0070.00016.51
7.4.250.0000.00816.55
7.4.240.0020.00516.58
7.4.230.0030.00516.63
7.4.220.0060.01316.52
7.4.210.0070.01016.58
7.4.200.0070.00016.45
7.4.160.0060.01016.77
7.4.150.0150.00317.40
7.4.140.0080.01517.86
7.4.130.0140.00516.54
7.4.120.0060.01116.58
7.4.110.0060.01216.56
7.4.100.0100.01316.53
7.4.90.0160.00716.76
7.4.80.0060.01219.39
7.4.70.0030.01316.54
7.4.60.0070.00916.55
7.4.50.0030.00316.74
7.4.40.0100.00716.54
7.4.30.0090.00916.78
7.4.00.0080.00815.01
7.3.330.0000.00513.27
7.3.320.0000.00613.32
7.3.310.0000.00716.45
7.3.300.0040.00416.45
7.3.290.0030.00316.50
7.3.280.0080.01116.42
7.3.270.0060.01217.40
7.3.260.0100.01016.66
7.3.250.0100.00816.58
7.3.240.0130.00316.39
7.3.230.0090.00916.50
7.3.210.0040.01216.55
7.3.200.0110.00716.68
7.3.190.0170.00016.45
7.3.180.0110.00816.47
7.3.170.0140.00716.54
7.3.160.0100.00716.43
7.3.120.0000.01914.64
7.3.110.0070.01115.09
7.3.100.0130.00614.83
7.3.90.0080.00614.86
7.3.80.0040.01114.56
7.3.70.0030.01014.68
7.3.60.0060.00914.85
7.3.50.0000.01514.42
7.3.40.0030.00514.50
7.3.30.0000.01514.78
7.3.20.0060.00916.63
7.3.10.0130.00616.48
7.3.00.0070.00716.78
7.2.330.0110.00616.78
7.2.320.0060.01616.89
7.2.310.0200.00316.87
7.2.300.0070.01016.87
7.2.290.0100.00716.51
7.2.250.0030.01315.32
7.2.240.0070.01315.18
7.2.230.0120.00315.22
7.2.220.0000.01415.08
7.2.210.0000.01415.01
7.2.200.0030.01415.22
7.2.190.0060.00314.78
7.2.180.0030.00914.77
7.2.170.0040.00414.78
7.2.160.0060.00915.18
7.2.150.0100.01017.09
7.2.140.0060.00317.07
7.2.130.0060.00917.11
7.2.120.0060.01216.70
7.2.110.0030.01316.80
7.2.100.0040.01216.64
7.2.90.0120.00316.84
7.2.80.0090.00616.92
7.2.70.0130.00316.83
7.2.60.0070.00816.88
7.2.50.0040.00816.82
7.2.40.0040.01116.93
7.2.30.0030.01016.57
7.2.20.0040.00816.82
7.2.10.0080.00316.87
7.2.00.0080.00818.30
7.1.330.0090.00915.45
7.1.320.0030.01015.81
7.1.310.0000.01215.85
7.1.300.0110.00415.49
7.1.290.0040.01115.47
7.1.280.0040.00415.76
7.1.270.0100.00715.73
7.1.260.0040.00715.84
7.1.250.0040.00815.54
7.1.240.0030.01315.73
7.1.230.0040.01215.52
7.1.220.0040.01115.80
7.1.210.0000.01615.66
7.1.200.0070.00515.69
7.1.190.0060.00915.71
7.1.180.0060.00315.86
7.1.170.0000.01515.55
7.1.160.0040.01115.75
7.1.150.0120.00315.87
7.1.140.0030.00915.86
7.1.130.0030.00615.73
7.1.120.0070.00715.83
7.1.110.0040.01115.92
7.1.100.0030.01117.18
7.1.90.0030.01015.86
7.1.80.0130.00015.87
7.1.70.0020.00716.50
7.1.60.0020.01517.48
7.1.50.0030.01316.38
7.1.40.0060.00616.01
7.1.30.0080.00615.81
7.1.20.0070.01015.77
7.1.10.0100.00315.84
7.1.00.0050.04218.86
7.0.330.0090.00315.11
7.0.320.0070.00715.06
7.0.310.0060.00615.41
7.0.300.0040.01115.35
7.0.290.0040.00715.13
7.0.280.0100.00315.49
7.0.270.0060.00615.21
7.0.260.0040.00815.24
7.0.250.0060.00315.17
7.0.240.0000.01415.50
7.0.230.0030.00715.36
7.0.220.0000.01315.46
7.0.210.0090.00615.32
7.0.200.0190.00715.04
7.0.190.0040.00415.03
7.0.180.0070.00715.43
7.0.170.0030.01315.48
7.0.160.0080.00315.56
7.0.150.0040.01114.92
7.0.140.0070.01015.29
7.0.130.0120.00015.45
7.0.120.0080.00315.40
7.0.110.0090.00315.35
7.0.100.0040.00415.26
7.0.90.0060.00615.27
7.0.80.0060.00315.41
7.0.70.0000.01415.39
7.0.60.0050.02317.56
7.0.50.0030.03516.76
7.0.40.0110.04316.74
7.0.30.0080.03616.83
7.0.20.0190.04216.87
7.0.10.0050.04716.79
7.0.00.0050.02516.74
5.6.400.0120.00014.16
5.6.390.0090.00614.20
5.6.380.0070.00714.45
5.6.370.0060.01014.57
5.6.360.0090.00414.37
5.6.350.0030.01014.23
5.6.340.0040.00414.45
5.6.330.0040.01114.40
5.6.320.0040.01114.40
5.6.310.0000.01014.41
5.6.300.0130.00313.99
5.6.290.0060.01214.56
5.6.280.0020.03317.63
5.6.270.0030.01414.30
5.6.260.0000.00814.32
5.6.250.0040.00814.36
5.6.240.0070.00414.47
5.6.230.0040.01114.16
5.6.220.0040.01114.43
5.6.210.0070.04017.49
5.6.200.0080.04316.38
5.6.190.0070.03217.47
5.6.180.0170.02317.42
5.6.170.0130.03017.40
5.6.160.0030.04717.23
5.6.150.0030.02616.19
5.6.140.0070.03116.20
5.6.130.0050.04516.14
5.6.120.0100.02517.69
5.6.110.0100.04217.60
5.6.100.0080.03817.67
5.6.90.0060.04217.57
5.6.80.0070.04217.31
5.6.70.0040.00814.44
5.6.60.0040.01214.37
5.6.50.0110.00414.39
5.6.40.0100.00014.48
5.6.30.0060.01114.15
5.6.20.0040.00413.89
5.6.10.0030.00514.34
5.6.00.0060.00614.39
5.5.380.0040.00814.40
5.5.370.0060.00614.34
5.5.360.0090.00314.39
5.5.350.0170.03517.09
5.5.340.0090.03215.88
5.5.330.0030.04817.33
5.5.320.0020.03917.11
5.5.310.0200.04017.34
5.5.300.0120.03516.20
5.5.290.0050.04116.15
5.5.280.0070.04417.77
5.5.270.0110.03917.71
5.5.260.0110.03917.54
5.5.250.0080.04417.40
5.5.240.0070.03917.18
5.5.230.0080.00314.13
5.5.220.0000.01014.15
5.5.210.0100.00314.08
5.5.200.0000.01113.90
5.5.190.0110.00414.04
5.5.180.0100.00714.10
5.5.170.0060.00613.95
5.5.160.0040.00713.92
5.5.150.0000.01414.40
5.5.140.0080.00414.08
5.5.130.0000.00813.85
5.5.120.0070.00413.95
5.5.110.0090.00014.27
5.5.100.0070.00714.09
5.5.90.0000.01313.84
5.5.80.0030.01013.98
5.5.70.0080.00314.12
5.5.60.0060.00914.05
5.5.50.0000.00913.88
5.5.40.0040.00714.37
5.5.30.0070.00314.34
5.5.20.0040.01214.26
5.5.10.0070.00713.73
5.5.00.0030.01014.05

preferences:
53.63 ms | 400 KiB | 5 Q