3v4l.org

run code in 300+ PHP versions simultaneously
<?phpgo function encode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i++) { $ordStr = ord(substr($string,$i,1)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36)); } return $hash; } function decode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i+=2) { $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= chr($ordStr - $ordKey); } return $hash; } echo encode("Please Encode Me!","This is a key"); echo decode(encode("Please Encode Me!","This is a key"),"This is a key"); ?>

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.0000.01818.43
8.3.50.0150.00721.21
8.3.40.0130.00618.71
8.3.30.0070.01020.31
8.3.20.0000.00722.27
8.3.10.0040.00422.12
8.3.00.0080.00022.43
8.2.180.0110.00416.50
8.2.170.0070.00722.96
8.2.160.0140.00320.28
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0050.00326.16
8.2.120.0080.00020.75
8.2.110.0030.00619.30
8.2.100.0060.00617.78
8.2.90.0000.00719.05
8.2.80.0060.00317.97
8.2.70.0000.00917.50
8.2.60.0110.00417.66
8.2.50.0060.00318.07
8.2.40.0030.00618.03
8.2.30.0040.00419.37
8.2.20.0000.00817.58
8.2.10.0080.00017.47
8.2.00.0000.00817.61
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.33
8.1.230.0120.00021.04
8.1.220.0000.00818.77
8.1.210.0000.00819.07
8.1.200.0030.00617.23
8.1.190.0040.00417.27
8.1.180.0060.00318.10
8.1.170.0050.00318.53
8.1.160.0000.00818.76
8.1.150.0000.00718.50
8.1.140.0100.00017.36
8.1.130.0000.00717.75
8.1.120.0000.00717.23
8.1.110.0000.00717.23
8.1.100.0040.00417.28
8.1.90.0030.00317.34
8.1.80.0000.00717.32
8.1.70.0030.00317.26
8.1.60.0060.00617.48
8.1.50.0000.00717.28
8.1.40.0040.00417.34
8.1.30.0040.00417.48
8.1.20.0030.00717.46
8.1.10.0030.00617.41
8.1.00.0000.00817.38
8.0.300.0000.00719.89
8.0.290.0040.00417.18
8.0.280.0030.00318.38
8.0.270.0000.00717.12
8.0.260.0000.00716.66
8.0.250.0000.00616.83
8.0.240.0090.00016.83
8.0.230.0000.00716.80
8.0.220.0030.00316.78
8.0.210.0030.00316.78
8.0.200.0000.00716.81
8.0.190.0030.00516.80
8.0.180.0070.00016.84
8.0.170.0030.00516.79
8.0.160.0040.00416.74
8.0.150.0000.00816.73
8.0.140.0070.00016.74
8.0.130.0030.00313.44
8.0.120.0040.00416.67
8.0.110.0040.00416.67
8.0.100.0040.00416.70
8.0.90.0040.00416.70
8.0.80.0090.00616.72
8.0.70.0040.00416.57
8.0.60.0000.00716.69
8.0.50.0000.00716.79
8.0.30.0080.01316.80
8.0.20.0090.00917.40
8.0.10.0040.00416.70
8.0.00.0080.00916.79
7.4.330.0070.00014.97
7.4.320.0040.00416.50
7.4.300.0000.00616.47
7.4.290.0000.00716.39
7.4.280.0030.00316.36
7.4.270.0000.00716.39
7.4.260.0000.00513.25
7.4.250.0070.00016.42
7.4.240.0020.00616.37
7.4.230.0030.00316.37
7.4.220.0110.00716.49
7.4.210.0100.00616.37
7.4.200.0030.00316.56
7.4.190.0000.00716.63
7.4.160.0060.00916.36
7.4.150.0120.01217.40
7.4.140.0140.00717.86
7.4.130.0030.01316.38
7.4.120.0110.00516.35
7.4.110.0120.00416.57
7.4.100.0030.01416.35
7.4.90.0030.01316.35
7.4.80.0100.01419.39
7.4.70.0090.00616.57
7.4.60.0060.01116.41
7.4.50.0000.00816.39
7.4.40.0060.00922.77
7.4.30.0130.00416.22
7.3.330.0030.00313.07
7.3.320.0050.00013.28
7.3.310.0000.00816.16
7.3.300.0000.00716.04
7.3.290.0070.00716.13
7.3.280.0080.00816.16
7.3.270.0040.01417.40
7.3.260.0140.00316.44
7.3.250.0090.00816.26
7.3.240.0100.01016.29
7.3.230.0070.01016.42
7.3.210.0120.00616.41
7.3.200.0150.00719.39
7.3.190.0150.00416.11
7.3.180.0110.01116.50
7.3.170.0120.00316.50
7.3.160.0120.00816.18
7.2.330.0100.00716.54
7.2.320.0090.00916.16
7.2.310.0100.00716.60
7.2.300.0030.01316.54
7.2.290.0110.00416.37
5.4.230.3500.03718.85
5.4.220.4030.04719.11
5.4.210.3530.03719.11
5.4.200.3430.03719.06
5.4.190.3400.03719.05
5.4.180.3000.04019.05
5.4.170.3800.04719.14
5.4.160.2900.04318.90
5.4.150.2870.03719.06
5.4.140.2600.04316.42
5.4.130.2770.03316.46
5.4.120.2030.04016.32
5.4.110.2270.03316.57
5.4.100.0670.03016.43
5.4.90.0200.05016.46
5.4.80.0270.05316.17
5.4.70.0170.04316.44
5.4.60.0200.04716.34
5.4.50.0270.04016.33
5.4.40.0270.03316.43
5.4.30.0330.04716.45
5.4.20.0230.04316.52
5.4.10.0270.04316.54
5.4.00.0300.06015.83
5.3.290.3630.04014.61
5.3.280.3300.03714.68
5.3.270.4070.03714.50
5.3.260.2630.03714.44
5.3.250.2270.04314.69
5.3.240.2900.03714.46
5.3.230.1800.03714.50
5.3.220.2170.03714.52
5.3.210.1600.02714.42
5.3.200.2330.03014.44
5.3.190.0230.03314.65
5.3.180.0200.04014.41
5.3.170.0200.03714.39
5.3.160.0170.04014.41
5.3.150.0230.05714.44
5.3.140.0270.05714.45
5.3.130.0270.06714.38
5.3.120.0170.04314.51
5.3.110.0230.04014.52
5.3.100.0430.05713.88
5.3.90.0200.04313.97
5.3.80.0270.04313.86
5.3.70.0400.04013.85
5.3.60.0330.03713.88
5.3.50.0270.04013.88
5.3.40.0330.04013.92
5.3.30.0330.04013.84
5.3.20.0270.03713.62
5.3.10.0470.03313.68
5.3.00.0470.05713.59

preferences:
59.4 ms | 400 KiB | 5 Q