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 = 'ICS2015'; $salt = '7'; $key = PBKDF1($pass, $salt, 100, 32); $iv = PBKDF1($pass, $salt, 100, 16); $encrypted = $foo->encrypt($key,$iv,'boy10@naver.com'); $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.0150.00416.75
8.3.50.0120.00621.23
8.3.40.0190.00318.98
8.3.30.0110.01118.84
8.3.20.0060.00320.16
8.3.10.0000.00823.48
8.3.00.0030.00723.54
8.2.180.0170.00018.41
8.2.170.0140.00022.96
8.2.160.0000.01420.56
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0030.00719.70
8.2.120.0070.00326.35
8.2.110.0100.00022.25
8.2.100.0040.00817.71
8.2.90.0040.00418.12
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0040.00422.32
8.2.30.0040.00420.76
8.2.20.0060.00317.68
8.2.10.0000.00718.07
8.2.00.0070.00018.05
8.1.280.0100.00725.92
8.1.270.0050.00322.26
8.1.260.0040.00428.09
8.1.250.0030.00528.09
8.1.240.0060.00322.36
8.1.230.0050.01021.04
8.1.220.0000.00817.74
8.1.210.0000.00818.84
8.1.200.0030.00717.35
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0030.00618.61
8.1.160.0040.00420.63
8.1.150.0000.00718.75
8.1.140.0040.00419.49
8.1.130.0000.00717.51
8.1.120.0000.00717.39
8.1.110.0040.00417.40
8.1.100.0050.00217.30
8.1.90.0000.00917.30
8.1.80.0000.00917.45
8.1.70.0030.00317.50
8.1.60.0050.00317.45
8.1.50.0030.00617.35
8.1.40.0040.00417.57
8.1.30.0040.00417.56
8.1.20.0040.00417.58
8.1.10.0000.00817.59
8.1.00.0040.00417.55
8.0.300.0000.00720.18
8.0.290.0060.00316.58
8.0.280.0000.00718.51
8.0.270.0000.00717.20
8.0.260.0030.00317.26
8.0.250.0000.00717.11
8.0.240.0000.00716.93
8.0.230.0000.00717.03
8.0.220.0040.00416.93
8.0.210.0030.00317.04
8.0.200.0030.00317.02
8.0.190.0040.00717.05
8.0.180.0000.00816.89
8.0.170.0040.00416.84
8.0.160.0000.00717.02
8.0.150.0000.00716.85
8.0.140.0000.00716.92
8.0.130.0030.00313.44
8.0.120.0000.00816.90
8.0.110.0040.00416.91
8.0.100.0000.00716.96
8.0.90.0000.00816.88
8.0.80.0110.00917.02
8.0.70.0050.00217.01
8.0.60.0050.00317.07
8.0.50.0040.00416.77
8.0.30.0120.00617.17
8.0.20.0110.01017.40
8.0.10.0000.00716.83
8.0.00.0120.00816.86
7.4.330.0060.00016.84
7.4.320.0030.00316.61
7.4.300.0060.00016.62
7.4.290.0040.00416.69
7.4.280.0030.00716.68
7.4.270.0030.00316.68
7.4.260.0040.00416.57
7.4.250.0000.00816.46
7.4.240.0070.00016.71
7.4.230.0070.00016.76
7.4.220.0100.01016.66
7.4.210.0070.00716.69
7.4.200.0050.00216.79
7.4.160.0030.01316.58
7.4.150.0180.01917.40
7.4.140.0160.00617.86
7.4.130.0140.01816.69
7.4.120.0120.00716.71
7.4.110.0120.00616.66
7.4.100.0100.01316.72
7.4.90.0080.01616.61
7.4.80.0060.01019.39
7.4.70.0050.01216.66
7.4.60.0060.01016.58
7.4.50.0060.00916.82
7.4.40.0070.01616.72
7.4.30.0090.00916.68
7.4.00.0070.01015.24
7.3.330.0000.00713.52
7.3.320.0030.00313.51
7.3.310.0040.00416.40
7.3.300.0030.00316.51
7.3.290.0030.00316.50
7.3.280.0090.00716.51
7.3.270.0130.01017.40
7.3.260.0110.00816.68
7.3.250.0050.01416.48
7.3.240.0060.01316.68
7.3.230.0060.01216.52
7.3.210.0110.00616.46
7.3.200.0100.00716.48
7.3.190.0070.01416.71
7.3.180.0110.00716.54
7.3.170.0050.01116.66
7.3.160.0070.01616.44
7.3.120.0070.01115.06
7.3.110.0040.01515.14
7.3.100.0080.00414.97
7.3.90.0090.00614.82
7.3.80.0100.00315.13
7.3.70.0000.01514.94
7.3.60.0070.00715.00
7.3.50.0120.00315.02
7.3.40.0100.00014.61
7.3.30.0090.00614.75
7.3.20.0070.00716.59
7.3.10.0090.00016.88
7.3.00.0030.00916.80
7.2.330.0100.00716.79
7.2.320.0080.00816.52
7.2.310.0080.00816.73
7.2.300.0150.00616.79
7.2.290.0130.00316.75
7.2.250.0100.01014.91
7.2.240.0090.00915.22
7.2.230.0040.01514.99
7.2.220.0030.01014.94
7.2.210.0090.00614.93
7.2.200.0030.01215.18
7.2.190.0000.01715.25
7.2.180.0040.01415.04
7.2.170.0060.00914.91
7.2.110.0210.00616.48
7.2.60.0070.00716.96
7.2.00.0070.01019.42
7.1.330.0000.01715.80
7.1.320.0080.00315.86
7.1.310.0070.00715.64
7.1.300.0060.00915.88
7.1.290.0060.00315.87
7.1.280.0110.00415.55
7.1.270.0090.00615.85
7.1.260.0000.01515.83
7.1.200.0030.01015.72
7.1.100.0000.01118.42
7.1.70.0060.00317.09
7.1.60.0120.00919.06
7.1.50.0100.01016.79
7.1.00.0030.07722.31
7.0.200.0120.00615.00
7.0.60.0070.07721.53
7.0.50.0030.07018.03
7.0.40.0130.08320.31
7.0.30.0330.07020.13
7.0.20.0270.07320.27
7.0.10.0100.05720.16
7.0.00.0070.04720.12
5.6.280.0030.06020.95
5.6.210.0070.08320.72
5.6.200.0130.08018.16
5.6.190.0030.04320.57
5.6.180.0200.04020.68
5.6.170.0170.05720.52
5.6.160.0130.08020.62
5.6.150.0030.08018.19
5.6.140.0070.08018.19
5.6.130.0100.08318.27
5.6.120.0070.04320.95
5.6.110.0030.08721.14
5.6.100.0100.08321.14
5.6.90.0130.07721.03
5.6.80.0030.04020.63
5.5.350.0170.07320.35
5.5.340.0100.07018.02
5.5.330.0000.05320.41
5.5.320.0570.06020.25
5.5.310.0270.03720.38
5.5.300.0070.08318.05
5.5.290.0000.05718.08
5.5.280.0030.05320.97
5.5.270.0070.08720.93
5.5.260.0070.04020.93
5.5.250.0200.06020.77
5.5.240.0130.07720.34

preferences:
92.19 ms | 401 KiB | 5 Q