3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(1); ini_set('display_errors', 1); class Encryption { private $key; protected $iv_size; protected $iv; public function __construct() { # --- ENCRYPTION --- # the key should be random binary, use scrypt, bcrypt or PBKDF2 to # convert a string into a key # key is specified using hexadecimal $this->key = pack("H*", "myKeyIsGreaterth2nanndbestofall04nkdsdffsd546754sdfvsdg6efflsdfs"); # create a random IV to use with CBC encoding $this->iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $this->iv = mcrypt_create_iv($this->iv_size, MCRYPT_RAND); } public function encryptData($input) { $output = $this->encrypt($input); return $output; } public function decryptData($input) { $input = base64_decode($input); $output = $this->decrypt($input); return $output; } protected function decrypt($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; } protected function encrypt($string) { # creates a cipher text compatible with AES (Rijndael block size = 128) # to keep the text confidential # only suitable for encoded input that never ends with value 00h # (because of default zero padding) $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); # === WARNING === # Resulting cipher text has no integrity or authenticity added # and is not protected against padding oracle attacks. return $output; } } $test = new Encryption(); $encrypted = $test->encryptData("Vicky"); echo "This is encrypted text of a string Vicky $encrypted \n"; echo "This is decrypted text ".$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.0090.00918.71
8.3.30.0070.00718.76
8.3.20.0080.00020.39
8.3.10.0090.00023.53
8.3.00.0080.00019.50
8.2.170.0110.00718.75
8.2.160.0120.00620.35
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0000.00820.33
8.2.120.0040.00426.35
8.2.110.0100.00721.10
8.2.100.0090.00317.66
8.2.90.0050.00317.91
8.2.80.0000.00817.97
8.2.70.0040.00417.93
8.2.60.0000.00817.91
8.2.50.0050.00518.10
8.2.40.0050.00319.30
8.2.30.0000.00720.70
8.2.20.0070.00317.75
8.2.10.0000.00717.94
8.2.00.0050.00318.00
8.1.270.0040.00423.91
8.1.260.0030.00528.09
8.1.250.0040.00428.09
8.1.240.0000.01019.14
8.1.230.0000.01222.67
8.1.220.0080.00017.74
8.1.210.0040.00418.83
8.1.200.0090.00017.21
8.1.190.0050.00517.10
8.1.180.0050.00318.10
8.1.170.0040.00418.51
8.1.160.0000.00821.91
8.1.150.0000.00718.65
8.1.140.0000.00819.50
8.1.130.0030.00317.60
8.1.120.0070.00017.25
8.1.110.0000.00817.24
8.1.100.0030.00617.29
8.1.90.0080.00317.32
8.1.80.0040.00417.26
8.1.70.0030.00517.34
8.1.60.0060.00317.61
8.1.50.0040.00417.45
8.1.40.0030.00517.56
8.1.30.0040.00417.50
8.1.20.0050.00417.59
8.1.10.0000.00717.61
8.1.00.0090.00017.53
8.0.300.0040.00421.95
8.0.290.0000.00816.75
8.0.280.0000.00718.32
8.0.270.0000.00717.20
8.0.260.0060.00017.21
8.0.250.0000.00716.97
8.0.240.0050.00316.92
8.0.230.0000.00716.87
8.0.220.0070.00016.91
8.0.210.0030.00516.94
8.0.200.0030.00316.96
8.0.190.0040.00416.96
8.0.180.0000.00716.96
8.0.170.0050.00316.83
8.0.160.0030.00416.98
8.0.150.0000.00716.76
8.0.140.0000.00816.75
8.0.130.0050.00013.39
8.0.120.0040.00416.88
8.0.110.0000.00816.91
8.0.100.0040.00416.92
8.0.90.0000.00716.92
8.0.80.0090.00616.89
8.0.70.0000.00716.83
8.0.60.0030.00516.89
8.0.50.0040.00416.94
8.0.30.0110.01116.97
8.0.20.0080.01217.41
8.0.10.0040.00417.05
8.0.00.0060.01116.85
7.4.330.0000.00516.85
7.4.320.0030.00316.48
7.4.300.0000.00616.41
7.4.290.0000.01116.55
7.4.280.0000.00816.45
7.4.270.0040.00416.56
7.4.260.0000.00716.56
7.4.250.0000.00816.55
7.4.240.0000.00716.51
7.4.230.0030.00316.62
7.4.220.0150.00916.39
7.4.210.0110.00716.60
7.4.200.0000.00716.29
7.4.160.0080.00816.39
7.4.150.0090.00917.40
7.4.140.0150.01717.86
7.4.130.0040.01716.55
7.4.120.0070.01216.62
7.4.110.0120.00616.54
7.4.100.0070.01116.52
7.4.90.0070.01016.36
7.4.80.0160.00619.39
7.4.70.0090.00916.36
7.4.60.0030.01216.41
7.4.50.0160.00016.45
7.4.40.0120.00316.38
7.4.30.0200.00316.71
7.4.00.0080.00815.10
7.3.330.0050.00013.20
7.3.320.0030.00313.41
7.3.310.0030.00516.41
7.3.300.0070.00016.34
7.3.290.0070.00816.35
7.3.280.0050.01316.38
7.3.270.0150.00317.40
7.3.260.0060.01216.43
7.3.250.0110.00716.50
7.3.240.0070.01216.49
7.3.230.0120.00616.46
7.3.210.0080.00816.42
7.3.200.0080.00816.33
7.3.190.0120.01016.37
7.3.180.0040.01816.28
7.3.170.0090.00916.57
7.3.160.0130.01716.39
7.3.10.0100.00316.64
7.3.00.0070.00716.63
7.2.330.0100.00716.60
7.2.320.0070.01016.54
7.2.310.0110.01516.66
7.2.300.0030.01716.57
7.2.290.0120.00916.72
7.2.130.0070.00716.79
7.2.120.0030.01016.92
7.2.110.0110.00316.56
7.2.100.0070.00716.82
7.2.90.0040.00816.90
7.2.80.0060.00616.79
7.2.70.0100.00016.71
7.2.60.0000.01816.34
7.2.50.0060.00916.93
7.2.40.0030.01016.76
7.2.30.0030.01316.89
7.2.20.0000.01716.70
7.2.10.0000.01716.54
7.2.00.0060.00616.75
7.1.250.0030.00615.49
5.6.150.0140.00014.13
5.6.140.0030.01014.11
5.6.130.0080.00814.16
5.6.120.0100.00714.05
5.6.110.0110.00614.06
5.6.100.0060.01014.21
5.6.90.0060.01014.30
5.6.80.0170.00013.97
5.6.70.0110.00713.80
5.6.60.0090.00913.82
5.6.50.0090.00614.14
5.6.40.0110.00314.21
5.6.30.0060.00914.08
5.6.20.0050.01314.14
5.6.10.0140.00314.11
5.6.00.0000.01214.38
5.5.300.0000.01110.68
5.5.290.0040.00811.14
5.5.280.0110.00011.23
5.5.270.0040.00811.09
5.5.260.0060.00611.08
5.5.250.0050.00510.98
5.5.240.0030.00611.08
5.5.230.0110.00010.96
5.5.220.0080.00310.76
5.5.210.0000.01111.01
5.5.200.0100.00210.89
5.5.190.0070.00610.98
5.5.180.0090.00411.06
5.5.170.0060.00913.71
5.5.160.0000.01311.09
5.5.150.0000.01010.93
5.5.140.0040.01010.84
5.5.130.0080.00310.97
5.5.120.0060.00311.06
5.5.110.0000.01310.94
5.5.100.0070.00710.89
5.5.90.0030.00710.95
5.5.80.0000.00910.82
5.5.70.0080.00411.02
5.5.60.0120.00010.85
5.5.50.0070.00410.88
5.5.40.0030.00611.04
5.5.30.0120.00011.17
5.5.20.0080.00410.83
5.5.10.0030.00911.22
5.5.00.0040.00710.68
5.4.450.0080.00310.95
5.4.440.0060.00510.68
5.4.430.0030.00810.67
5.4.420.0050.00510.91
5.4.410.0090.00010.93
5.4.400.0060.00610.80
5.4.390.0070.00310.91
5.4.380.0040.00810.70
5.4.370.0060.00310.76
5.4.360.0050.00510.57
5.4.350.0060.00610.90
5.4.340.0070.00310.86
5.4.330.0100.00010.74
5.4.320.0040.00810.79
5.4.310.0040.00710.54
5.4.300.0000.01210.88
5.4.290.0030.00610.84
5.4.280.0060.00611.00
5.4.270.0000.01110.48
5.4.260.0000.01310.67
5.4.250.0090.00310.95
5.4.240.0050.00510.64
5.4.230.0030.00610.81
5.4.220.0040.00910.79
5.4.210.0030.00810.93
5.4.200.0000.01110.70
5.4.190.0070.00410.87
5.4.180.0060.00310.59
5.4.170.0040.00710.55
5.4.160.0050.00310.88
5.4.150.0000.00810.87
5.4.140.0060.00910.89
5.4.130.0060.00610.85
5.4.120.0030.00710.89
5.4.110.0040.00810.78
5.4.100.0030.00610.85
5.4.90.0000.01110.82
5.4.80.0000.01211.00
5.4.70.0030.00710.94
5.4.60.0040.00810.84
5.4.50.0040.00610.81
5.4.40.0100.00010.73
5.4.30.0030.00710.84
5.4.20.0000.01010.75
5.4.10.0000.00910.98
5.4.00.0060.00610.93
5.3.290.0000.01310.66
5.3.280.0000.01110.49
5.3.270.0060.00610.51
5.3.260.0000.01010.60
5.3.250.0060.00610.55
5.3.240.0000.00810.41
5.3.230.0100.00010.25
5.3.220.0100.00210.39
5.3.210.0040.00710.20
5.3.200.0080.00010.45
5.3.190.0030.00510.46
5.3.180.0000.01010.64
5.3.170.0020.00510.58
5.3.160.0070.00310.51
5.3.150.0030.00710.53
5.3.140.0030.00610.44
5.3.130.0000.00910.55
5.3.120.0000.01010.40
5.3.110.0050.00510.34
5.3.100.0060.00310.23
5.3.90.0070.00310.36
5.3.80.0050.00510.26
5.3.70.0000.00710.14
5.3.60.0030.00710.36
5.3.50.0030.00610.41
5.3.40.0090.00310.40
5.3.30.0030.00710.11
5.3.20.0060.00310.43
5.3.10.0090.00010.04
5.3.00.0050.00510.09
5.2.170.0070.0009.46
5.2.160.0060.0039.46
5.2.150.0030.0039.48
5.2.140.0050.0059.46
5.2.130.0030.0039.46
5.2.120.0000.0079.46
5.2.110.0060.0009.46
5.2.100.0080.0009.46
5.2.90.0060.0039.48
5.2.80.0000.0089.46
5.2.70.0060.0039.46
5.2.60.0070.0029.46
5.2.50.0110.0009.46
5.2.40.0050.0029.46
5.2.30.0020.0099.46
5.2.20.0060.0039.46
5.2.10.0000.0099.46
5.2.00.0040.0049.46
5.1.60.0050.0029.46
5.1.50.0050.0039.46
5.1.40.0080.0009.46
5.1.30.0000.0089.46
5.1.20.0100.0009.46
5.1.10.0030.0039.46
5.1.00.0060.0039.46
5.0.50.0030.0039.46
5.0.40.0030.0039.46
5.0.30.0000.0089.46
5.0.20.0030.0039.46
5.0.10.0050.0009.46
5.0.00.0030.0039.46
4.4.90.0000.0069.46
4.4.80.0040.0049.46
4.4.70.0040.0009.46
4.4.60.0000.0049.46
4.4.50.0000.0049.46
4.4.40.0030.0039.46
4.4.30.0000.0049.46
4.4.20.0030.0039.46
4.4.10.0020.0029.46
4.4.00.0020.0029.46
4.3.110.0000.0049.46
4.3.100.0000.0059.46
4.3.90.0050.0039.46
4.3.80.0040.0009.46
4.3.70.0000.0049.46
4.3.60.0030.0039.46
4.3.50.0000.0059.46
4.3.40.0030.0039.46
4.3.30.0030.0039.46
4.3.20.0050.0009.46
4.3.10.0000.0059.46
4.3.00.0040.0009.46

preferences:
62.37 ms | 400 KiB | 5 Q