3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Helper library for CryptoJS AES encryption/decryption * Allow you to use AES encryption on client side and server side vice versa * * @author BrainFooLong (bfldev.com) * @link https://github.com/brainfoolong/cryptojs-aes-php */ /** * Decrypt data from a CryptoJS json encoding string * * @param mixed $passphrase * @param mixed $jsonString * @return mixed */ function cryptoJsAesDecrypt($passphrase, $jsonString){ $jsondata = json_decode($jsonString, true); $salt = hex2bin($jsondata["s"]); $ct = base64_decode($jsondata["ct"]); $iv = hex2bin($jsondata["iv"]); $concatedPassphrase = $passphrase.$salt; $md5 = array(); $md5[0] = md5($concatedPassphrase, true); $result = $md5[0]; for ($i = 1; $i < 3; $i++) { $md5[$i] = md5($md5[$i - 1].$concatedPassphrase, true); $result .= $md5[$i]; } $key = substr($result, 0, 32); $data = openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv); return json_decode($data, true); } /** * Encrypt value to a cryptojs compatiable json encoding string * * @param mixed $passphrase * @param mixed $value * @return string */ function cryptoJsAesEncrypt($passphrase, $value){ $salt = openssl_random_pseudo_bytes(8); $salted = ''; $dx = ''; while (strlen($salted) < 48) { $dx = md5($dx.$passphrase.$salt, true); $salted .= $dx; } $key = substr($salted, 0, 32); $iv = substr($salted, 32,16); $encrypted_data = openssl_encrypt(json_encode($value), 'aes-256-cbc', $key, true, $iv); $data = array("ct" => base64_encode($encrypted_data), "iv" => bin2hex($iv), "s" => bin2hex($salt)); return json_encode($data); } echo cryptoJsAeaEncrypt("test", "foo");

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.0100.01017.73
8.4.10.0000.00917.74
8.3.150.0110.00817.16
8.3.140.0070.00418.77
8.3.130.0050.00318.49
8.3.120.0060.00318.78
8.3.110.0040.00420.94
8.3.100.0060.00324.06
8.3.90.0000.00826.77
8.3.80.0100.00016.63
8.3.70.0070.00718.54
8.3.60.0120.00616.75
8.3.50.0130.00521.20
8.3.40.0070.00718.67
8.3.30.0140.00719.07
8.3.20.0000.00720.00
8.3.10.0080.00021.73
8.3.00.0040.00419.11
8.2.270.0130.00317.40
8.2.260.0080.00316.96
8.2.250.0040.00417.09
8.2.240.0080.00017.05
8.2.230.0040.00422.58
8.2.220.0070.00337.54
8.2.210.0040.00426.77
8.2.200.0060.00316.63
8.2.190.0120.00617.00
8.2.180.0160.00616.75
8.2.170.0110.00322.96
8.2.160.0140.00020.47
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00419.72
8.2.110.0040.00421.00
8.2.100.0090.00317.72
8.2.90.0030.00517.72
8.2.80.0000.00819.16
8.2.70.0050.00317.50
8.2.60.0000.00917.50
8.2.50.0040.00417.55
8.2.40.0040.00418.00
8.2.30.0040.00418.01
8.2.20.0070.00017.78
8.2.10.0000.00717.95
8.2.00.0060.00617.95
8.1.310.0040.00416.34
8.1.300.0060.00320.02
8.1.290.0030.00630.84
8.1.280.0070.00725.92
8.1.270.0110.00420.29
8.1.260.0070.00026.35
8.1.250.0100.01028.09
8.1.240.0060.00322.14
8.1.230.0040.00720.88
8.1.220.0040.00417.74
8.1.210.0050.00520.14
8.1.200.0080.00317.13
8.1.190.0050.00317.23
8.1.180.0060.00319.03
8.1.170.0040.00418.72
8.1.160.0000.00818.72
8.1.150.0050.00318.55
8.1.140.0000.00717.34
8.1.130.0030.00317.81
8.1.120.0040.00417.44
8.1.110.0000.00817.40
8.1.100.0040.00417.37
8.1.90.0000.00717.33
8.1.80.0040.00417.28
8.1.70.0070.00017.22
8.1.60.0040.00417.48
8.1.50.0050.00517.39
8.1.40.0030.00617.36
8.1.30.0030.00617.52
8.1.20.0050.00317.49
8.1.10.0040.00417.62
8.1.00.0050.00317.38
8.0.300.0040.00420.11
8.0.290.0080.00016.88
8.0.280.0000.00718.42
8.0.270.0030.00317.29
8.0.260.0080.00016.92
8.0.250.0030.00317.04
8.0.240.0040.00416.96
8.0.230.0050.00217.01
8.0.220.0070.00016.82
8.0.210.0000.00817.00
8.0.200.0030.00317.03
8.0.190.0030.00616.96
8.0.180.0000.00816.96
8.0.170.0070.00016.88
8.0.160.0040.00416.95
8.0.150.0000.00816.80
8.0.140.0040.00416.90
8.0.130.0040.00313.38
8.0.120.0050.00216.80
8.0.110.0050.00216.98
8.0.100.0000.00716.85
8.0.90.0000.00816.97
8.0.80.0070.01417.00
8.0.70.0000.00716.73
8.0.60.0070.00016.91
8.0.50.0070.00016.88
8.0.30.0070.01216.99
8.0.20.0150.00717.40
8.0.10.0000.00816.89
8.0.00.0060.01216.78
7.4.330.0000.00615.03
7.4.320.0000.00716.52
7.4.300.0030.00316.51
7.4.290.0070.00016.51
7.4.280.0030.00516.46
7.4.270.0070.00016.44
7.4.260.0000.00716.57
7.4.250.0050.00216.55
7.4.240.0020.00616.46
7.4.230.0000.00716.39
7.4.220.0100.01016.61
7.4.210.0150.00016.61
7.4.200.0040.00416.32
7.4.160.0170.00316.33
7.4.150.0100.01017.40
7.4.140.0150.00717.86
7.4.130.0130.00516.71
7.4.120.0100.01016.57
7.4.110.0070.01016.39
7.4.100.0100.01316.48
7.4.90.0030.01416.30
7.4.80.0130.01019.39
7.4.70.0100.00616.61
7.4.60.0060.01016.56
7.4.50.0070.00016.33
7.4.40.0120.00916.40
7.4.30.0150.00616.49
7.3.330.0080.00013.33
7.3.320.0030.00313.18
7.3.310.0040.00416.42
7.3.300.0000.00616.35
7.3.290.0080.00716.33
7.3.280.0080.01116.32
7.3.270.0110.00617.40
7.3.260.0040.01416.30
7.3.250.0080.01116.37
7.3.240.0150.00816.35
7.3.230.0070.01016.61
7.3.210.0090.00916.24
7.3.200.0100.00719.39
7.3.190.0050.01116.39
7.3.180.0110.01116.21
7.3.170.0110.00616.41
7.3.160.0180.00316.59
7.2.330.0140.02716.61
7.2.320.0070.01016.25
7.2.310.0140.00716.51
7.2.300.0120.00616.60
7.2.290.0030.01316.57
7.2.00.0040.00819.46
7.1.70.0040.00417.16
7.1.60.0140.01019.48
7.1.50.0040.02116.87
7.1.00.0070.07022.33
7.0.200.0030.00816.67
7.0.110.0600.08320.09
7.0.100.0530.07319.98
7.0.90.0630.08320.07
7.0.80.0670.06721.71
7.0.70.0100.05719.95
7.0.60.0130.07320.11
7.0.50.0130.08020.46
7.0.40.0130.06320.04
7.0.30.0070.08320.29
7.0.20.0030.08020.13
7.0.10.0070.08320.14
7.0.00.0100.07720.07
5.6.280.0100.06320.90
5.6.250.0070.08320.87
5.6.240.0030.08020.68
5.6.230.0100.07720.70
5.6.220.0100.07720.68
5.6.210.0030.05020.59
5.6.200.0100.08021.20
5.6.190.0070.08721.11
5.6.180.0000.08721.06
5.6.170.0130.08020.94
5.6.160.0170.07021.15
5.6.150.0130.07321.10
5.6.140.0100.07320.93
5.6.130.0100.08320.96
5.6.120.0100.07721.08
5.6.110.0070.07720.98
5.6.100.0100.08021.28
5.6.90.0100.08021.13
5.6.80.0000.08720.32
5.6.70.0000.09020.33
5.6.60.0030.07320.41
5.6.50.0030.07320.45
5.6.40.0130.07020.30
5.6.30.0070.08020.43
5.6.20.0070.07720.29
5.6.10.0100.07720.45
5.6.00.0130.07020.59
5.5.380.0200.06020.48
5.5.370.0100.08320.57
5.5.360.0130.08020.28
5.5.350.0000.09320.46
5.5.340.0100.06020.91
5.5.330.0100.08320.82
5.5.320.0070.08020.82
5.5.310.0070.05020.96
5.5.300.0030.08020.77
5.5.290.0130.07720.99
5.5.280.0200.06720.98
5.5.270.0030.06020.95
5.5.260.0130.07320.98
5.5.250.0100.05720.60
5.5.240.0170.06320.38
5.5.230.0170.07020.16
5.5.220.0030.07320.29
5.5.210.0070.07720.29
5.5.200.0130.05320.11
5.5.190.0070.06320.14
5.5.180.0070.07320.17
5.5.160.0100.07720.26
5.5.150.0130.07320.16
5.5.140.0100.07020.26
5.5.130.0100.07020.16
5.5.120.0070.04720.22
5.5.110.0030.07320.04
5.5.100.0000.08020.11
5.5.90.0030.07320.06
5.5.80.0000.05320.24
5.5.70.0000.07320.02
5.5.60.0030.06720.02
5.5.50.0130.06720.19
5.5.40.0030.08720.08
5.5.30.0100.07020.04
5.5.20.0170.06319.99
5.5.10.0100.07020.23
5.5.00.0070.07020.14
5.4.450.0100.07319.56
5.4.440.0130.04319.36
5.4.430.0100.07319.63
5.4.420.0070.04719.56
5.4.410.0070.06319.20
5.4.400.0100.07319.32
5.4.390.0100.07019.18
5.4.380.0000.05718.98
5.4.370.0070.07718.95
5.4.360.0170.03319.24
5.4.350.0070.05319.18
5.4.340.0030.07019.23
5.4.320.0130.06018.93
5.4.310.0100.06719.00
5.4.300.0200.06318.95
5.4.290.0100.07719.16
5.4.280.0100.05719.16
5.4.270.0100.04019.01
5.4.260.0130.03719.09
5.4.250.0100.07019.03
5.4.240.0070.07319.02
5.4.230.0100.07019.18
5.4.220.0070.07719.01
5.4.210.0070.04719.16
5.4.200.0030.08019.22
5.4.190.0030.04319.15
5.4.180.0070.05018.98
5.4.170.0030.07718.94
5.4.160.0030.04718.94
5.4.150.0000.08319.08
5.4.140.0030.07316.59
5.4.130.0070.05716.61
5.4.120.0100.03716.33
5.4.110.0200.03316.41
5.4.100.0030.07016.53
5.4.90.0030.06316.32
5.4.80.0030.07716.54
5.4.70.0070.06316.63
5.4.60.0070.05016.39
5.4.50.0100.07316.52
5.4.40.0030.07016.46
5.4.30.0030.05716.39
5.4.20.0070.06716.53
5.4.10.0030.07716.23
5.4.00.0100.06315.75
5.3.290.0100.07014.54
5.3.280.0130.07014.75
5.3.270.0030.07714.63
5.3.260.0070.07014.75
5.3.250.0070.07314.63
5.3.240.0070.06714.59
5.3.230.0070.05714.64
5.3.220.0070.06714.60
5.3.210.0030.07714.66
5.3.200.0070.07714.80
5.3.190.0000.06014.72
5.3.180.0030.04714.70
5.3.170.0030.07714.80
5.3.160.0100.06714.70
5.3.150.0100.06014.70
5.3.140.0100.07014.66
5.3.130.0030.04014.57
5.3.120.0100.07314.59
5.3.110.0100.06714.59
5.3.100.0070.07714.07
5.3.90.0070.06714.05
5.3.80.0070.04014.11
5.3.70.0030.05014.11
5.3.60.0030.07714.00
5.3.50.0070.07313.92
5.3.40.0070.07314.09
5.3.30.0000.04713.88
5.3.20.0070.07013.74
5.3.10.0030.04313.52
5.3.00.0130.06313.64
5.2.170.0070.06011.16
5.2.160.0000.06711.18
5.2.150.0030.06311.18
5.2.140.0030.06011.28
5.2.130.0030.06311.21
5.2.120.0070.05311.12
5.2.110.0070.05711.24
5.2.100.0070.05311.09
5.2.90.0100.05311.13
5.2.80.0030.06711.20
5.2.70.0030.06711.10
5.2.60.0030.04311.02
5.2.50.0000.04711.18
5.2.40.0070.06311.03
5.2.30.0030.05710.98
5.2.20.0070.03010.96
5.2.10.0100.05310.89
5.2.00.0030.06010.82
5.1.60.0000.05710.01
5.1.50.0070.05010.02
5.1.40.0070.0509.96
5.1.30.0070.05310.40
5.1.20.0000.05710.61
5.1.10.0070.04710.07
5.1.00.0000.05010.09
5.0.50.0100.0439.19
5.0.40.0030.0439.19
5.0.30.0130.0579.19
5.0.20.0000.0479.19
5.0.10.0070.0409.19
5.0.00.0000.0709.19
4.4.90.0070.0309.19
4.4.80.0000.0339.19
4.4.70.0030.0279.19
4.4.60.0070.0309.19
4.4.50.0070.0309.19
4.4.40.0030.0539.19
4.4.30.0030.0179.19
4.4.20.0000.0379.19
4.4.10.0000.0379.19
4.4.00.0000.0539.19
4.3.110.0030.0339.19
4.3.100.0000.0339.19
4.3.90.0000.0339.19
4.3.80.0000.0609.19
4.3.70.0000.0339.19
4.3.60.0000.0339.19
4.3.50.0030.0339.19
4.3.40.0000.0539.19
4.3.30.0000.0379.19
4.3.20.0070.0309.19
4.3.10.0000.0339.19
4.3.00.0000.0379.19

preferences:
35.27 ms | 403 KiB | 5 Q