3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mcryptPadKey($key, $cipher, $blockMode) { $td = mcrypt_module_open($cipher, '', $blockMode, ''); $size = mcrypt_enc_get_key_size($td); mcrypt_module_close($td); //echo "- " . strlen($key) . " - " . $size . "\n\n"; if (strlen($key) === 0) { $key = str_repeat("\0", $size); } else if (strlen($key) > $size) { return substr($key, 0, $size); } else if (strlen($key) % $size) { $key = $key.str_repeat("\0", $size - (strlen($key) % $size)); } return $key; } function mcryptPadIV($iv, $cipher, $blockMode) { $td = mcrypt_module_open($cipher, '', $blockMode, ''); $size = mcrypt_enc_get_block_size($td); mcrypt_module_close($td); echo "- " . strlen($iv) . " - " . $size . "\n\n"; if (strlen($iv) != $size) { echo 'ok: ' . str_repeat("\0", $size); return str_repeat("\0", $size); } else { return $iv; } } function mcryptPadData($data, $cipher, $blockMode) { if (!is_scalar($data) && $data !== null) { return $data; } $td = mcrypt_module_open($cipher, '', $blockMode, ''); $size = mcrypt_enc_get_block_size($td); mcrypt_module_close($td); //echo "- " . strlen($data) . " - " . $size . "\n\n"; if (strlen($data) < $size) { return str_pad($data, $size, "\0"); } else { return $data; } } function mcryptDataConvert($mixed, $strict = false) { if (is_string($mixed)) { return $mixed; } if ( is_array($mixed) || is_object($mixed) && !method_exists($mixed, '__toString') || is_resource($mixed) ) { return $strict ? null : ''; } else if ($mixed === null) { return ''; } else { return (string)$mixed; } } function encode($input, $mode = "ASCII") { $res = ""; switch ($mode) { case "ASCII": for($i = 0; $i < strlen($input); $i++) $res .= ord($input[$i])."-"; break; case "hex": $unpack = unpack('H*', $input); $res = array_shift($unpack); break; default: $res = $input; break; } return $res; } $data = "52824616"; $key = "khfTiNtfrZ8554khfTiNtf\0\0"; $iv = base64_decode('w1Uy6MvHZNY='); $output = "hex"; echo $iv . "\n\n"; $my_key = $key; $my_key .= substr($my_key,0,8); $iv = $iv !== null ? $iv : "ÃU2èËÇdÖ"; $data = mcryptPadData($data, MCRYPT_3DES, MCRYPT_MODE_CBC); $my_key2 = mcryptPadKey($my_key, MCRYPT_3DES, MCRYPT_MODE_CBC); $iv2 = mcryptPadIV($iv, MCRYPT_3DES, MCRYPT_MODE_CBC); $crypt = mcrypt_encrypt(MCRYPT_3DES, $my_key2, $data, MCRYPT_MODE_CBC, $iv2); echo 'data: ' . $data . "\n"; echo 'key2: ' . $my_key2 . "\n"; echo 'iv2: ' . $iv2 . "\n"; echo $crypt . "\n\n"; echo encode($crypt, $output) . "\n";

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.5.10.0120.00916.91
8.5.00.0130.00820.08
8.4.150.0020.00114.05
8.4.140.0110.01017.86
8.4.130.0090.00918.82
8.4.120.0050.00424.44
8.4.110.0090.00820.30
8.4.100.0150.00518.94
8.4.90.0070.01320.66
8.4.80.0040.00520.55
8.4.70.0060.00519.09
8.4.60.0120.00918.66
8.4.50.0060.00218.67
8.4.40.0040.01917.80
8.4.30.0170.00319.83
8.4.20.0040.00717.82
8.4.10.0070.01420.42
8.3.280.0100.01118.64
8.3.270.0150.00516.99
8.3.260.0100.01016.71
8.3.250.0100.00919.04
8.3.240.0110.00817.11
8.3.230.0080.01016.51
8.3.220.0150.00419.04
8.3.210.0070.00216.75
8.3.200.0050.00416.74
8.3.190.0100.01019.21
8.3.180.0060.00418.75
8.3.170.0070.01116.70
8.3.160.0180.00018.90
8.3.150.0090.00917.02
8.3.140.0130.00619.11
8.3.130.0030.00618.72
8.3.120.0050.00519.19
8.3.110.0060.00320.94
8.3.100.0030.00624.06
8.3.90.0030.00526.77
8.3.80.0090.00316.98
8.3.70.0130.00717.00
8.3.60.0090.00918.58
8.3.50.0070.00717.55
8.3.40.0110.00418.97
8.3.30.0160.00018.93
8.3.20.0050.00319.23
8.3.10.0000.00721.90
8.3.00.0030.00619.68
8.2.290.0100.00820.50
8.2.280.0120.00718.48
8.2.270.0070.01118.68
8.2.260.0120.00616.82
8.2.250.0130.00316.75
8.2.240.0100.00717.16
8.2.230.0100.00022.58
8.2.220.0060.00337.54
8.2.210.0000.00826.77
8.2.200.0040.00716.88
8.2.190.0060.01218.54
8.2.180.0130.00716.88
8.2.170.0120.00622.96
8.2.160.0110.00419.39
8.2.150.0030.00524.18
8.2.140.0080.00024.66
8.2.130.0040.00419.89
8.2.120.0030.00526.35
8.2.110.0030.00622.20
8.2.100.0040.00718.16
8.2.90.0040.00419.17
8.2.80.0040.00417.97
8.2.70.0060.00318.05
8.2.60.0040.00418.05
8.2.50.0040.00418.10
8.2.40.0060.00319.30
8.2.30.0000.01019.57
8.2.20.0000.00718.10
8.2.10.0060.00318.08
8.2.00.0080.00019.46
8.1.330.0140.00522.00
8.1.320.0120.00818.72
8.1.310.0090.00916.53
8.1.300.0000.00818.41
8.1.290.0000.00930.84
8.1.280.0100.00725.92
8.1.270.0070.00023.84
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00022.75
8.1.230.0090.00318.01
8.1.220.0060.00317.89
8.1.210.0040.00418.77
8.1.200.0070.00317.48
8.1.190.0080.00017.35
8.1.180.0000.00818.10
8.1.170.0000.00818.71
8.1.160.0040.00418.96
8.1.150.0070.00018.91
8.1.140.0050.00317.83
8.1.130.0000.00719.08
8.1.120.0040.00417.50
8.1.110.0040.00417.44
8.1.100.0030.00517.53
8.1.90.0030.00517.48
8.1.80.0050.00317.50
8.1.70.0030.00317.51
8.1.60.0080.00017.61
8.1.50.0050.00317.60
8.1.40.0090.00017.47
8.1.30.0000.00817.60
8.1.20.0030.00617.76
8.1.10.0030.00617.61
8.1.00.0030.00517.50
8.0.300.0000.00818.77
8.0.290.0080.00017.00
8.0.280.0070.00018.44
8.0.270.0040.00417.35
8.0.260.0040.00417.21
8.0.250.0070.00017.02
8.0.240.0060.00317.01
8.0.230.0000.00816.93
8.0.220.0000.00717.03
8.0.210.0000.00716.98
8.0.200.0000.00617.14
8.0.190.0070.00017.05
8.0.180.0040.00416.95
8.0.170.0040.00416.89
8.0.160.0000.00717.14
8.0.150.0070.00016.96
8.0.140.0040.00416.98
8.0.130.0000.00613.52
8.0.120.0040.00417.00
8.0.110.0000.00817.02
8.0.100.0050.00316.91
8.0.90.0040.00417.01
8.0.80.0120.00616.99
8.0.70.0030.00616.98
8.0.60.0000.00716.93
8.0.50.0000.00716.93
8.0.30.0130.00617.18
8.0.20.0100.01117.40
8.0.10.0050.00217.14
8.0.00.0070.01016.78
7.4.330.0050.00015.55
7.4.320.0000.00716.50
7.4.300.0070.00016.52
7.4.290.0000.00716.58
7.4.280.0030.00516.65
7.4.270.0070.00316.68
7.4.260.0030.00316.61
7.4.250.0040.00416.54
7.4.240.0050.00316.63
7.4.230.0050.00216.34
7.4.220.0030.00516.55
7.4.210.0080.00716.67
7.4.200.0000.00716.68
7.4.160.0110.00516.58
7.4.140.0100.00917.86
7.4.130.0150.00416.57
7.4.120.0110.00916.60
7.4.110.0030.01716.46
7.4.100.0110.00616.65
7.4.90.0070.01316.72
7.4.80.0090.00919.39
7.4.70.0140.00416.37
7.4.60.0080.01216.67
7.4.50.0070.01016.63
7.4.40.0070.01516.53
7.4.00.0110.00414.89
7.3.330.0000.00513.46
7.3.320.0030.00313.50
7.3.310.0040.00416.32
7.3.300.0030.00316.37
7.3.290.0030.00316.45
7.3.280.0100.00816.56
7.3.260.0090.00916.70
7.3.240.0100.00816.64
7.3.230.0170.00016.45
7.3.210.0170.00316.48
7.3.200.0060.01616.50
7.3.190.0160.00716.50
7.3.180.0080.00816.50
7.3.170.0070.01016.63
7.3.160.0030.01516.44
7.2.330.0120.00616.68
7.2.320.0070.01216.85
7.2.310.0110.00716.55
7.2.300.0050.01516.93
7.2.290.0150.00816.62
7.2.60.0120.00316.92
7.2.40.1440.01017.66
7.2.30.1580.01017.85
7.2.20.1710.00818.00
7.2.10.1220.01117.99
7.2.00.1260.01117.96
7.1.200.0030.00615.76
7.1.160.1320.01216.81
7.1.150.1580.01016.92
7.1.140.1270.01016.88
7.1.130.1450.00817.10
7.1.120.1150.00816.84
7.1.110.1070.01016.29
7.1.100.1060.01016.22
7.1.90.0990.00916.38
7.1.80.0970.00816.33
7.1.70.1060.00615.26
7.1.60.1300.00933.21
7.1.50.1640.02032.72
7.1.40.1760.01432.70
7.1.30.1370.01232.79
7.1.20.1650.01032.89
7.1.10.1570.01014.89
7.1.00.1150.01114.86

preferences:
36.91 ms | 403 KiB | 5 Q