3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $mcrypt_cipher = MCRYPT_RIJNDAEL_128; protected $mcrypt_mode = MCRYPT_MODE_CBC; public function decrypt($key, $iv, $encrypted) { return mcrypt_decrypt($this->mcrypt_cipher, $key, base64_decode($encrypted), $this->mcrypt_mode, $iv); } public function encrypt($key, $iv, $password) { $block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $padding = $block - (strlen($password) % $block); $password .= str_repeat(chr($padding), $padding); return mcrypt_encrypt($this->mcrypt_cipher, $key, $password, $this->mcrypt_mode, $iv); } } $foo = new Foo; $pass = 'p@ss'; $salt = 's@1t'; $key = PBKDF1($pass, $salt, 2, 32); $iv = "@1B2c3D4e5F6g7H8"; $encrypted = $foo->encrypt($key,$iv,'test@123'); $encrypted = base64_encode($encrypted); echo 'Encrypted: '.$encrypted.'</br>'; echo 'Decrypted: '.$foo->decrypt($key, $iv, $encrypted); function PBKDF1($pass, $salt, $count, $cb) { static $base; static $extra; static $extracount= 0; static $hashno; static $state = 0; if ($state == 0) { $hashno = 0; $state = 1; $key = $pass . $salt; $base = sha1($key, true); for($i = 2; $i < $count; $i++) { $base = sha1($base, true); } } $result = ""; if ($extracount > 0) { $rlen = strlen($extra) - $extracount; if ($rlen >= $cb) { $result = substr($extra, $extracount, $cb); if ($rlen > $cb) { $extracount += $cb; } else { $extra = null; $extracount = 0; } return $result; } $result = substr($extra, $rlen, $rlen); } $current = ""; $clen = 0; $remain = $cb - strlen($result); while ($remain > $clen) { if ($hashno == 0) { $current = sha1($base, true); } else if ($hashno < 1000) { $n = sprintf("%d", $hashno); $tmp = $n . $base; $current .= sha1($tmp, true); } $hashno++; $clen = strlen($current); } // $current now holds at least as many bytes as we need $result .= substr($current, 0, $remain); // Save any left over bytes for any future requests if ($clen > $remain) { $extra = $current; $extracount = $remain; } return $result; }

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.0060.00916.88
8.3.50.0130.00721.15
8.3.40.0120.00318.76
8.3.30.0040.01118.63
8.3.20.0080.00020.30
8.3.10.0040.00423.53
8.3.00.0040.00423.61
8.2.180.0100.01016.75
8.2.170.0150.00618.80
8.2.160.0000.01422.96
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0060.00617.91
8.2.120.0030.00726.35
8.2.110.0050.00522.30
8.2.100.0080.00417.91
8.2.90.0040.00419.07
8.2.80.0050.00317.97
8.2.70.0030.00617.63
8.2.60.0080.00017.93
8.2.50.0040.00418.07
8.2.40.0050.00322.34
8.2.30.0040.00420.66
8.2.20.0000.00717.65
8.2.10.0040.00418.00
8.2.00.0040.00418.06
8.1.280.0130.00625.92
8.1.270.0060.00322.14
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0030.00623.96
8.1.230.0080.00319.14
8.1.220.0080.00017.74
8.1.210.0000.00918.77
8.1.200.0000.01017.23
8.1.190.0000.00917.11
8.1.180.0040.00418.10
8.1.170.0000.00818.55
8.1.160.0000.00720.74
8.1.150.0040.00418.75
8.1.140.0030.00619.49
8.1.130.0000.00717.54
8.1.120.0050.00217.36
8.1.110.0030.00517.41
8.1.100.0040.00417.41
8.1.90.0040.00417.39
8.1.80.0040.00417.39
8.1.70.0070.00017.42
8.1.60.0060.00317.53
8.1.50.0030.00617.32
8.1.40.0040.00417.50
8.1.30.0000.00917.56
8.1.20.0070.00317.66
8.1.10.0050.00317.53
8.1.00.0000.00817.43
8.0.300.0080.00018.77
8.0.290.0070.00016.88
8.0.280.0070.00018.29
8.0.270.0040.00417.25
8.0.260.0060.00017.17
8.0.250.0080.00016.91
8.0.240.0000.00716.99
8.0.230.0030.00316.97
8.0.220.0000.00716.86
8.0.210.0000.00716.86
8.0.200.0040.00416.95
8.0.190.0000.00816.90
8.0.180.0040.00416.97
8.0.170.0030.00616.96
8.0.160.0050.00316.86
8.0.150.0040.00416.82
8.0.140.0040.00416.82
8.0.130.0050.00013.37
8.0.120.0070.00316.85
8.0.110.0040.00416.86
8.0.100.0040.00416.82
8.0.90.0040.00416.86
8.0.80.0070.00716.89
8.0.70.0040.00417.00
8.0.60.0030.00617.07
8.0.50.0080.00016.77
8.0.30.0090.00616.97
8.0.20.0120.00717.40
8.0.10.0000.00817.07
8.0.00.0130.00616.86
7.4.330.0000.00616.86
7.4.320.0000.00616.58
7.4.300.0030.00316.66
7.4.290.0000.00716.56
7.4.280.0000.01016.53
7.4.270.0070.00016.59
7.4.260.0040.00416.54
7.4.250.0000.00816.57
7.4.240.0030.00416.56
7.4.230.0030.00316.64
7.4.220.0050.00516.68
7.4.210.0080.00716.69
7.4.200.0000.00716.45
7.4.160.0170.00016.67
7.4.150.0030.01417.40
7.4.140.0130.00917.86
7.4.130.0070.01016.66
7.4.120.0120.00616.61
7.4.110.0100.00716.57
7.4.100.0100.00716.33
7.4.90.0100.01016.42
7.4.80.0080.00819.39
7.4.70.0100.00716.72
7.4.60.0070.01016.56
7.4.50.0070.01016.50
7.4.40.0160.00316.61
7.4.30.0100.01316.52
7.4.00.0070.01014.99
7.3.330.0000.00613.25
7.3.320.0000.00513.43
7.3.310.0030.00316.46
7.3.300.0030.00316.52
7.3.290.0030.00316.34
7.3.280.0060.00916.47
7.3.270.0070.01017.40
7.3.260.0080.00816.48
7.3.250.0100.01016.65
7.3.240.0140.00716.60
7.3.230.0120.00616.43
7.3.210.0060.00916.53
7.3.200.0080.00819.39
7.3.190.0090.01316.63
7.3.180.0120.00416.52
7.3.170.0120.00916.41
7.3.160.0070.01016.59
7.2.330.0060.01216.88
7.2.320.0060.01016.82
7.2.310.0070.01016.66
7.2.300.0180.00616.77
7.2.290.0180.00416.69
7.2.60.0060.01016.84
7.1.200.0060.00615.89
7.1.70.0040.00716.92
7.1.60.0130.01319.06
7.1.50.0100.00317.02
7.1.00.0000.08022.35
7.0.200.0150.00714.82
7.0.60.0030.05321.53
7.0.50.0100.07717.95
7.0.40.0130.08320.29
7.0.30.0200.04320.25
7.0.20.0230.08720.27
7.0.10.0070.08720.27
7.0.00.0200.04320.22
5.6.210.0100.07020.63
5.6.200.0130.06718.24
5.6.190.0030.09020.34
5.6.180.0330.03320.34
5.6.170.0230.08320.53
5.6.160.0030.05020.45
5.6.150.0070.09018.20
5.6.140.0000.05018.25
5.6.130.0030.08018.18
5.6.120.0070.04721.14
5.6.110.0030.09021.11
5.6.100.0130.07321.04
5.6.90.0070.08321.19
5.6.80.0030.05320.49
5.5.350.0170.04020.32
5.5.340.0070.08018.10
5.5.330.0130.04320.28
5.5.320.0470.07020.25
5.5.310.0200.03720.30
5.5.300.0070.05318.02
5.5.290.0070.04317.94
5.5.280.0070.04320.90
5.5.270.0100.08320.82
5.5.260.0070.04320.79
5.5.250.0070.07720.64
5.5.240.0200.08320.21

preferences:
35.22 ms | 401 KiB | 5 Q