3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string='test data'; $output = ''; $encrypt_method = 'AES-256-CTR'; $key = random_bytes(32); // Store long-term $secret_iv = random_bytes(16); $encryption_key = hash_hkdf('sha256', $key, 32, 'encryption'); $authentication_key = hash_hkdf('sha256', $key, 32, 'authentication'); $unauthenticated = openssl_encrypt( $string, $encrypt_method, $encryption_key, OPENSSL_RAW_DATA, $secret_iv ); // NEW: Add an HMAC $hmac = hash_hmac('sha256', $secret_iv . $unauthenticated, $authentication_key, true); $output = base64_encode($hmac . $secret_iv . $unauthenticated); var_dump($output);

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.0.00.0040.01316.51
7.4.130.0070.01516.38
7.4.120.0130.00616.50
7.4.110.0070.01016.51
7.4.100.0070.01116.31
7.4.90.0050.01116.46
7.4.80.0060.01116.59
7.4.70.0090.00916.50
7.4.60.0060.01116.42
7.4.50.0110.00616.61
7.4.40.0060.01216.43
7.4.30.0080.01116.39
7.4.20.0080.01016.40
7.4.10.0070.01016.44
7.4.00.0100.00916.36
7.3.250.0150.00616.56
7.3.240.0100.00616.12
7.3.230.0110.00616.45
7.3.220.0120.00616.58
7.3.210.0160.00016.35
7.3.200.0070.01016.40
7.3.190.0100.00616.28
7.3.180.0040.01316.18
7.3.170.0120.00616.09
7.3.160.0070.01116.28
7.3.150.0140.01016.37
7.3.140.0090.00916.44
7.3.130.0020.01616.20
7.3.120.0130.00715.64
7.3.110.0080.00915.32
7.3.100.0100.00915.30
7.3.90.0210.00815.30
7.3.80.0120.00715.09
7.3.70.0150.00915.15
7.3.60.0130.01015.08
7.3.50.0170.00814.99
7.3.40.0100.00714.90
7.3.30.0120.00614.94
7.3.20.0170.01015.42
7.3.10.0180.01015.51
7.3.00.0140.00715.57
7.2.340.0130.00616.55
7.2.330.0190.00616.34
7.2.320.0130.00516.59
7.2.310.0060.01316.64
7.2.300.0070.01316.70
7.2.290.0030.01516.34
7.2.280.0130.01216.43
7.2.270.0070.01216.71
7.2.260.0110.01016.57
7.2.250.0100.00716.52
7.2.240.0070.00815.85
7.2.230.0100.00715.78
7.2.220.0090.01115.48
7.2.210.0110.01215.38
7.2.200.0200.01115.28
7.2.190.0090.01115.29
7.2.180.0070.01015.11
7.2.170.0070.00915.17
7.2.160.0090.00915.08
7.2.150.0150.00815.67
7.2.140.0180.00715.80
7.2.130.0180.00715.87
7.2.120.0150.01015.86
7.2.110.0220.00915.83
7.2.100.0170.00815.85
7.2.90.0190.00915.98
7.2.80.0180.00715.86
7.2.70.0190.00815.92
7.2.60.0170.00815.90
7.2.50.0190.01015.87
7.2.40.0160.00715.90
7.2.30.0190.00715.95
7.2.20.0170.01015.93
7.2.10.0130.00915.92
7.2.00.0180.00816.10
7.1.330.0140.00615.21
7.1.320.0220.00514.67
7.1.310.0200.01014.60
7.1.300.0190.01014.59
7.1.290.0140.00914.64
7.1.280.0210.00814.65
7.1.270.0180.00814.54
7.1.260.0240.01214.61
7.1.250.0170.00814.77
7.1.240.0280.00814.53
7.1.230.0220.00714.59
7.1.220.0210.00914.60
7.1.210.0240.00714.50
7.1.200.0280.00714.68
7.1.190.0220.00814.56
7.1.180.0230.00614.59
7.1.170.0240.00714.61
7.1.160.0280.00914.53
7.1.150.0250.00914.51
7.1.140.0270.00814.53
7.1.130.0210.01214.60
7.1.120.0220.00814.88
7.1.110.0280.00714.85
7.1.100.0210.00814.81
7.1.90.0220.00814.82
7.1.80.0250.00814.79
7.1.70.0220.00814.66
7.1.60.0240.00916.96
7.1.50.0250.00616.94
7.1.40.0230.00916.88
7.1.30.0250.00816.83
7.1.20.0220.01016.90
7.1.10.0250.00914.68
7.1.00.0280.00914.59
7.0.330.0240.00614.08
7.0.320.0240.01014.09
7.0.310.0390.00514.15
7.0.300.0240.00514.10
7.0.290.0410.00814.12
7.0.280.0200.00914.03
7.0.270.0250.00614.03
7.0.260.0220.01114.50
7.0.250.0310.00714.40
7.0.240.0240.00914.42
7.0.230.0300.00914.38
7.0.220.0250.00814.44
7.0.210.0190.00914.17
7.0.200.0220.00914.11
7.0.190.0220.01114.27
7.0.180.0260.00814.13
7.0.170.0300.00914.12
7.0.160.0210.01114.09
7.0.150.0250.01114.29
7.0.140.0240.01214.21
7.0.130.0230.00914.37
7.0.120.0260.00614.38
7.0.110.0250.00814.38
7.0.100.0260.00814.29
7.0.90.0200.00814.36
7.0.80.0240.00814.26
7.0.70.0230.01314.30
7.0.60.0240.01014.28
7.0.50.0210.01114.25
7.0.40.0290.01014.38
7.0.30.0230.00714.30
7.0.20.0230.01014.33
7.0.10.0190.00714.37
7.0.00.0200.00914.23
5.6.400.0120.01114.47
5.6.390.0170.00814.71
5.6.380.0110.01114.60
5.6.370.0160.00814.65
5.6.360.0130.01114.64
5.6.350.0210.00414.67
5.6.340.0110.01114.75
5.6.330.0140.00814.69
5.6.320.0220.00914.73
5.6.310.0240.00814.80
5.6.300.0170.02016.05
5.6.290.0160.01915.99
5.6.280.0160.01816.06
5.6.270.0170.01516.18
5.6.260.0150.01816.13
5.6.250.0130.01916.11
5.6.240.0130.02116.10
5.6.230.0120.02616.05
5.6.220.0100.02315.91
5.6.210.0150.02116.10
5.6.200.0160.02215.99
5.6.190.0150.01715.95
5.6.180.0130.02016.06
5.6.170.0130.01816.02
5.6.160.0150.01816.02
5.6.150.0120.02216.05
5.6.140.0170.02016.02
5.6.130.0150.01816.06
5.6.120.0130.02316.09
5.6.110.0130.02016.05
5.6.100.0160.01715.97
5.6.90.0110.02015.97
5.6.80.0200.02015.88
5.6.70.0120.02015.80
5.6.60.0130.01915.91
5.6.50.0140.01715.85
5.6.40.0150.01915.82
5.6.30.0140.02115.77
5.6.20.0140.01815.90
5.6.10.0160.01915.84
5.6.00.0150.01715.85
5.3.00.0050.00012.73

preferences:
28.6 ms | 401 KiB | 5 Q