3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. class Cryptor { protected $method = 'AES-128-CTR'; // default private $key; protected function iv_bytes() { return openssl_cipher_iv_length($this->method); } public function __construct($key = FALSE, $method = FALSE) { if(!$key) { // if you don't supply your own key, this will be the default $key = gethostname() . "|" . ip2long($_SERVER['SERVER_ADDR']); } if(ctype_print($key)) { // convert key to binary format $this->key = openssl_digest($key, 'SHA256', TRUE); } else { $this->key = $key; } if($method) { if(in_array($method, openssl_get_cipher_methods())) { $this->method = $method; } else { die(__METHOD__ . ": unrecognised encryption method: {$method}"); } } } public function encrypt($data) { $iv = openssl_random_pseudo_bytes($this->iv_bytes()); $encrypted_string = bin2hex($iv) . openssl_encrypt($data, $this->method, $this->key, 0, $iv); return $encrypted_string; } // decrypt encrypted string public function decrypt($data) { $iv_strlen = 2 * $this->iv_bytes(); if(preg_match("/^(.{" . $iv_strlen . "})(.+)$/", $data, $regs)) { list(, $iv, $crypted_string) = $regs; $decrypted_string = openssl_decrypt($crypted_string, $this->method, $this->key, 0, hex2bin($iv)); return $decrypted_string; } else { return FALSE; } } } $token = "The quick brown fox jumps over the lazy dog."; $encryption_key = 'CKXH2U9RPY3EFD70TLS1ZG4N8WQBOVI6AMJ5'; $cryptor = new Cryptor($encryption_key); $crypted_token = $cryptor->encrypt($token); unset($token); echo $crypted_token;

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.60.0080.00818.28
8.3.50.0150.00017.98
8.3.40.0060.01218.84
8.3.30.0070.00718.65
8.3.20.0070.00019.29
8.3.10.0080.00023.51
8.3.00.0090.00020.40
8.2.180.0110.00416.88
8.2.170.0150.00022.96
8.2.160.0070.00720.39
8.2.150.0030.00524.18
8.2.140.0000.00824.66
8.2.130.0030.00617.91
8.2.120.0040.00426.35
8.2.110.0060.00320.35
8.2.100.0090.00317.72
8.2.90.0000.00719.52
8.2.80.0060.00317.97
8.2.70.0000.00817.93
8.2.60.0000.00818.16
8.2.50.0050.00318.10
8.2.40.0040.00419.34
8.2.30.0080.00019.18
8.2.20.0040.00418.03
8.2.10.0080.00318.05
8.2.00.0030.00617.82
8.1.280.0110.00425.92
8.1.270.0040.00420.65
8.1.260.0050.00326.35
8.1.250.0000.00828.09
8.1.240.0000.01021.98
8.1.230.0060.00620.87
8.1.220.0000.00817.79
8.1.210.0050.00318.88
8.1.200.0000.00817.35
8.1.190.0030.00617.23
8.1.180.0000.00818.10
8.1.170.0030.00518.68
8.1.160.0000.00718.89
8.1.150.0000.00718.95
8.1.140.0040.00422.19
8.1.130.0040.00420.36
8.1.120.0000.00717.52
8.1.110.0030.00517.47
8.1.100.0040.00417.47
8.1.90.0050.00317.54
8.1.80.0000.00817.48
8.1.70.0030.00317.39
8.1.60.0000.00817.63
8.1.50.0050.00317.63
8.1.40.0030.00617.45
8.1.30.0040.00417.69
8.1.20.0080.00017.65
8.1.10.0030.00617.61
8.1.00.0030.00617.53
8.0.300.0070.00020.02
8.0.290.0040.00416.88
8.0.280.0040.00418.39
8.0.270.0000.00717.21
8.0.260.0070.00018.36
8.0.250.0070.00017.05
8.0.240.0000.00617.04
8.0.230.0000.00717.11
8.0.220.0000.00717.05
8.0.210.0030.00616.99
8.0.200.0030.00316.99
8.0.190.0040.00416.95
8.0.180.0000.00817.00
8.0.170.0060.00317.07
8.0.160.0000.00817.12
8.0.150.0040.00716.97
8.0.140.0040.00416.91
8.0.130.0000.00613.41
8.0.120.0030.00516.86
8.0.110.0040.00416.89
8.0.100.0080.00017.03
8.0.90.0000.00716.78
8.0.80.0100.00816.97
8.0.70.0040.00416.87
8.0.60.0030.00517.09
8.0.50.0000.00716.96
8.0.30.0170.00017.27
8.0.20.0060.01317.40
8.0.10.0040.00417.15
8.0.00.0090.01016.84
7.4.330.0050.00015.55
7.4.320.0060.00016.70
7.4.300.0000.00716.55
7.4.290.0030.00316.53
7.4.280.0000.00716.59
7.4.270.0040.00416.54
7.4.260.0100.00016.63
7.4.250.0030.00516.63
7.4.240.0040.00416.69
7.4.230.0030.00316.55
7.4.220.0080.00016.29
7.4.210.0100.00816.60
7.4.200.0000.00716.36
7.4.160.0100.00716.54
7.4.140.0140.00517.86
7.4.130.0090.00916.57
7.4.120.0110.00716.75
7.4.110.0120.00616.56
7.4.100.0080.00916.76
7.4.90.0100.00716.57
7.4.80.0070.01019.39
7.4.70.0100.00716.51
7.4.60.0030.01316.52
7.4.50.0040.00816.66
7.4.40.0090.01516.53
7.4.00.0030.01214.90
7.3.330.0030.00313.45
7.3.320.0050.00013.42
7.3.310.0000.00916.36
7.3.300.0030.00316.52
7.3.290.0000.00716.34
7.3.280.0060.00916.48
7.3.260.0120.00716.64
7.3.240.0110.01016.41
7.3.230.0070.01016.60
7.3.210.0040.01416.34
7.3.200.0120.01216.40
7.3.190.0120.00916.34
7.3.180.0140.00716.65
7.3.170.0190.00316.70
7.3.160.0150.00416.77
7.3.10.0100.00616.55
7.3.00.0080.00516.26
7.2.330.0000.01716.32
7.2.320.0120.00416.44
7.2.310.0110.00616.76
7.2.300.0070.01316.25
7.2.290.0110.00716.55
7.2.130.0020.01016.49
7.2.120.0020.01116.42
7.2.110.0400.01015.79
7.2.100.0440.01015.89
7.2.90.0390.00216.12
7.2.80.0420.00915.92
7.2.70.0130.01115.94
7.2.60.0190.01016.03
7.2.50.0220.01416.04
7.2.40.0510.01016.32
7.2.30.0200.01116.18
7.2.20.0490.01016.14
7.2.10.0310.00916.16
7.2.00.0280.00515.99
7.1.250.0050.00815.41
7.1.230.1200.01013.35
7.1.220.0890.00713.68
7.1.210.1140.01513.78
7.1.200.0900.01013.58
7.1.190.0300.00413.69
7.1.180.0790.00313.43
7.1.170.0750.00713.61
7.1.160.0760.00713.50
7.1.150.0700.00913.78
7.1.140.0660.00314.04
7.1.130.0610.00613.98
7.1.120.1360.01514.04
7.1.110.0830.00713.71
7.1.100.0550.00613.94
7.1.90.0590.00613.73
7.1.80.0790.01313.89
7.1.70.0570.00713.64
7.1.60.1140.01032.08
7.1.50.0670.01531.88
7.1.40.0800.00631.80
7.1.30.0760.00731.83
7.1.20.0450.01031.41
7.1.10.0270.01013.54
7.1.00.0300.00713.69
5.6.380.0140.00913.96

preferences:
43.81 ms | 401 KiB | 5 Q