3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = "wpdPVWejqNRYqDTeUJ2Iw06/rnfHAoy5jtgTojiilD0="; $pwd = "ICS2015"; $salt = "7"; $enc = Encrypt("boy10@naver.com", $pwd, $salt); echo "Enc: " . $enc . "\r\n"; $dec = Decrypt($data, $pwd, $salt); echo "Dec: " . $dec . "\r\n"; function Decrypt($ciphertext, $password, $salt) { $ciphertext = base64_decode($ciphertext); $key = PBKDF1($password, $salt, 100, 32); $iv = PBKDF1($password, $salt, 100, 16); echo "bb" . base64_encode($iv); // NB: Need 128 not 256 and CBC mode to be compatible $decpad = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext, MCRYPT_MODE_CBC, $iv); $pad = ord($decpad[($len = strlen($decpad)) - 1]); $dec = substr($decpad, 0, strlen($decpad) - $pad); return $dec; } function Encrypt($ciphertext, $password, $salt) { $key = PBKDF1($password, $salt, 100, 32); $iv = PBKDF1($password, $salt, 100, 16); echo "aa" . base64_encode($iv); return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext, MCRYPT_MODE_CBC, $iv)); } 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; } ?>
based on 88DA5

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.110.1400.01616.08
7.2.60.0090.00616.89
7.2.00.0000.01219.50
7.1.200.0030.00615.81
7.1.100.0050.00518.18
7.1.70.0090.00617.36
7.1.60.0100.01419.06
7.1.50.0030.01016.98
7.1.00.0070.07322.30
7.0.200.0140.00714.95
7.0.60.0230.07321.71
7.0.50.0070.03718.17
7.0.40.0070.06320.09
7.0.30.0170.04320.13
7.0.20.0300.08020.33
7.0.10.0030.04720.21
7.0.00.0070.05320.27
5.6.280.0100.05321.12
5.6.210.0100.05320.71
5.6.200.0070.08718.16
5.6.190.0030.04720.52
5.6.180.0400.07320.41
5.6.170.0230.05020.55
5.6.160.0070.08020.55
5.6.150.0030.08318.26
5.6.140.0130.08018.24
5.6.130.0030.06318.19
5.6.120.0100.03321.09
5.6.110.0070.08721.23
5.6.100.0170.07721.09
5.6.90.0030.06021.05
5.6.80.0200.07020.49
5.5.350.0230.07720.40
5.5.340.0000.09018.15
5.5.330.0030.04320.32
5.5.320.0230.07720.42
5.5.310.0230.09020.42
5.5.300.0030.04717.98
5.5.290.0030.08318.02
5.5.280.0170.07720.98
5.5.270.0070.06320.84
5.5.260.0100.08320.79
5.5.250.0000.04320.77
5.5.240.0070.07320.29
5.4.450.0570.02319.57
5.4.440.0500.07319.57
5.4.430.0500.06019.39
5.4.420.0370.04719.41
5.4.410.0500.07319.17
5.4.400.0400.04719.07
5.4.390.0430.07319.23
5.4.380.0470.06719.07
5.4.370.0400.05719.23
5.4.360.0500.06719.04
5.4.350.0430.04019.27
5.4.340.0530.06719.27
5.4.320.0330.03719.14
5.4.310.0370.04719.20
5.4.300.0270.04318.98
5.4.290.0500.05719.22
5.4.280.0570.06319.00
5.4.270.0400.04319.13
5.4.260.0430.04719.27
5.4.250.0470.04719.26
5.4.240.0330.04018.97
5.4.230.0370.04019.14
5.4.220.0400.03319.18
5.4.210.0430.05019.18
5.4.200.0400.06318.96
5.4.190.0500.06719.05
5.4.180.0400.04019.05
5.4.170.0500.04719.00
5.4.160.0500.06018.95
5.4.150.0500.06019.05
5.4.140.0470.06716.35
5.4.130.0430.06016.40
5.4.120.0470.05316.45
5.4.110.0430.06016.50
5.4.100.0330.04716.27
5.3.290.0270.04714.85
5.3.280.0400.04314.70
5.3.270.0370.04714.68
5.3.260.0470.06714.79
5.3.250.0630.03314.71
5.3.240.0370.04314.71
5.3.230.0300.04714.68
5.3.220.0470.05314.60
5.3.210.0330.04014.59
5.3.200.0570.05714.60