3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(1); ini_set('display_errors', 1); class Encryption { private $key = "myKeyIs"; protected $iv_size; protected $iv; public function __construct(){ $this->iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $this->iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); } public function encryptData($input) { $output = $this->encrypt($input); return $output; } public function decryptData($input) { $output = $this->decrypt($input); return $output; } public function decrypt($string) { $string = base64_decode(base64_decode($string)); # retrieves the IV, iv_size should be created using mcrypt_get_iv_size() $iv_dec = substr($string, 0, $this->iv_size); # retrieves the cipher text (everything except the $iv_size in the front) $string = substr($string, $this->iv_size); # may remove 00h valued characters from end of plain text $output = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->key, $string, MCRYPT_MODE_CBC, $iv_dec); return $output; } public function encrypt($string) { $output = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, $string, MCRYPT_MODE_CBC, $this->iv); # prepend the IV for it to be available for decryption $output = $this->iv . $output; # encode the resulting cipher text so it can be represented by a string $output = base64_encode($output); return $output; } } $test = new Encryption(); $encrypted = $test->encryptData("Vicky"); echo $encrypted."\n"; echo $test->decryptData($encrypted);

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.84
8.3.30.0160.00018.86
8.3.20.0040.00420.38
8.3.10.0080.00023.52
8.3.00.0040.00419.38
8.2.170.0100.01018.97
8.2.160.0030.01322.96
8.2.150.0040.00425.66
8.2.140.0030.00524.66
8.2.130.0060.00320.45
8.2.120.0080.00026.16
8.2.110.0030.00620.48
8.2.100.0030.01018.04
8.2.90.0060.00319.26
8.2.80.0080.00017.97
8.2.70.0040.00417.50
8.2.60.0080.00417.80
8.2.50.0040.00418.07
8.2.40.0030.00520.93
8.2.30.0030.00320.54
8.2.20.0000.00917.77
8.2.10.0050.00218.09
8.2.00.0040.00417.93
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00324.03
8.1.230.0070.00319.10
8.1.220.0040.00417.74
8.1.210.0060.00318.77
8.1.200.0050.00517.22
8.1.190.0000.00917.34
8.1.180.0080.00018.10
8.1.170.0060.00318.52
8.1.160.0050.00321.89
8.1.150.0040.00418.79
8.1.140.0060.00319.39
8.1.130.0070.00017.54
8.1.120.0040.00417.28
8.1.110.0040.00417.35
8.1.100.0000.00717.38
8.1.90.0070.00017.43
8.1.80.0050.00217.37
8.1.70.0000.00817.29
8.1.60.0030.00617.54
8.1.50.0000.00817.37
8.1.40.0050.00317.51
8.1.30.0030.00517.55
8.1.20.0080.00017.54
8.1.10.0040.00417.57
8.1.00.0000.00817.55
8.0.300.0040.00418.77
8.0.290.0040.00416.63
8.0.280.0000.00718.33
8.0.270.0030.00317.15
8.0.260.0030.00317.17
8.0.250.0040.00417.02
8.0.240.0040.00416.90
8.0.230.0070.00017.01
8.0.220.0000.00716.77
8.0.210.0060.00316.80
8.0.200.0000.00617.02
8.0.190.0070.00016.98
8.0.180.0030.00516.84
8.0.170.0070.00016.94
8.0.160.0040.00416.95
8.0.150.0040.00316.80
8.0.140.0040.00316.82
8.0.130.0030.00313.37
8.0.120.0040.00416.86
8.0.110.0000.00716.88
8.0.100.0000.00716.92
8.0.90.0040.00417.03
8.0.80.0060.00916.92
8.0.70.0080.00016.91
8.0.60.0030.00516.76
8.0.50.0000.00816.92
8.0.30.0090.00917.21
8.0.20.0150.00517.40
8.0.10.0000.00717.05
8.0.00.0110.00716.77
7.4.330.0000.00616.67
7.4.320.0030.00316.32
7.4.300.0000.00616.46
7.4.290.0030.00316.43
7.4.280.0060.00316.56
7.4.270.0030.00316.48
7.4.260.0030.00716.55
7.4.250.0040.00416.55
7.4.240.0050.00216.53
7.4.230.0070.00016.27
7.4.220.0100.01016.53
7.4.210.0100.01016.60
7.4.200.0040.00416.59
7.4.160.0160.00316.56
7.4.150.0130.00317.40
7.4.140.0090.00917.86
7.4.130.0120.00716.50
7.4.120.0090.00816.60
7.4.110.0110.00816.62
7.4.100.0080.01116.52
7.4.90.0090.00916.53
7.4.80.0030.01519.39
7.4.70.0000.01716.38
7.4.60.0110.00716.64
7.4.50.0040.01516.71
7.4.40.0000.01716.35
7.4.30.0170.00016.46
7.4.00.0120.00514.94
7.3.330.0000.00513.37
7.3.320.0000.00513.18
7.3.310.0070.00016.39
7.3.300.0000.00716.41
7.3.290.0090.00916.40
7.3.280.0140.00416.39
7.3.270.0090.00917.40
7.3.260.0140.00316.51
7.3.250.0130.00616.36
7.3.240.0080.01316.30
7.3.230.0030.01416.39
7.3.210.0160.00016.46
7.3.200.0030.01316.30
7.3.190.0100.00616.49
7.3.180.0060.01216.46
7.3.170.0130.01016.38
7.3.160.0170.00616.50
7.3.120.0070.01014.68
7.3.110.0070.00714.91
7.3.100.0040.01515.00
7.3.90.0060.00614.91
7.3.80.0100.00315.09
7.3.70.0040.01114.61
7.3.60.0070.00314.60
7.3.50.0060.00314.86
7.3.40.0100.00314.95
7.3.30.0060.00914.50
7.3.20.0120.00616.39
7.3.10.0090.00316.66
7.3.00.0030.00616.24
7.2.330.0110.01116.46
7.2.320.0130.00616.53
7.2.310.0090.01016.59
7.2.300.0090.00816.41
7.2.290.0140.00316.65
7.2.250.0070.01015.09
7.2.240.0070.01114.86
7.2.230.0070.01014.63
7.2.220.0000.01414.61
7.2.210.0030.00715.05
7.2.200.0030.01114.75
7.2.190.0070.01114.82
7.2.180.0000.01314.99
7.2.170.0100.01014.95
7.2.110.0130.00716.52
7.2.60.0070.00716.91
7.2.00.0030.00919.14
7.1.330.0000.01515.59
7.1.320.0040.01115.76
7.1.310.0100.00715.91
7.1.300.0070.01015.47
7.1.290.0030.01015.71
7.1.280.0040.01515.39
7.1.270.0070.01015.63
7.1.260.0040.01115.43
7.1.200.0030.01015.77
7.1.100.0110.00418.04
7.1.70.0040.00416.99
7.1.60.0100.01419.36
7.1.50.0040.01816.55
7.1.00.0000.08022.43
7.0.200.0040.00416.78
7.0.60.0070.03719.86
7.0.50.0130.08017.96
7.0.40.0070.06020.15
7.0.30.0300.08020.22
7.0.20.0270.07020.06
7.0.10.0100.07320.30
7.0.00.0100.04320.06
5.6.280.0000.05720.79
5.6.210.0070.06720.62
5.6.200.0070.05318.23
5.6.190.0130.06720.52
5.6.180.0500.07720.67
5.6.170.0200.05320.62
5.6.160.0100.08320.58
5.6.150.0100.04718.24
5.6.140.0100.08018.13
5.6.130.0100.05718.19
5.6.120.0000.05321.03
5.6.110.0000.05321.02
5.6.100.0200.06321.11
5.6.90.0130.08321.11
5.6.80.0030.07020.53
5.5.350.0170.08020.38
5.5.340.0130.07718.02
5.5.330.0000.05720.28
5.5.320.0030.07320.39
5.5.310.0330.05020.38
5.5.300.0100.05718.05
5.5.290.0100.07317.99
5.5.280.0000.05020.90
5.5.270.0000.07320.85
5.5.260.0170.07320.98
5.5.250.0000.05720.70
5.5.240.0230.07020.24

preferences:
49.32 ms | 400 KiB | 5 Q