3v4l.org

run code in 300+ PHP versions simultaneously
<?php class encryption_class { var $scramble1; // 1st string of ASCII characters var $scramble2; // 2nd string of ASCII characters var $errors; // array of error messages var $adj; // 1st adjustment value (optional) var $mod; // 2nd adjustment value (optional) function encryption_class () { // Each of these two strings must contain the same characters, but in a different order. // Use only printable characters from the ASCII table. // Each character can only appear once in each string EXCEPT for the first character // which must be duplicated at the end (this gets round a bijou problemette when the // first character of the password is also the first character in $scramble1) $this->scramble1 = '! "#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!'; $this->scramble2 = 'f^jAE]okI\OzU[2&q1{3`h5w_794p@6s8?BgP>dFV=m D<TcS%Ze|r:lGK/uCy.Jx)HiQ!"#$\'~(;Lt-R}Ma,NvW+Ynb*0Xf'; if (strlen($this->scramble1) <> strlen($this->scramble2)) { $this->errors[] = '** SCRAMBLE1 is not same length as SCRAMBLE2 **'; } // if $this->adj = 1.75; // this value is added to the rolling fudgefactors $this->mod = 3; // if divisible by this the adjustment is made negative } // constructor function encrypt ($key, $source, $sourcelen=0) { $this->errors = array(); $fudgefactor = $this->_convertKey($key); if ($this->errors) return; if (empty($source)) { $this->errors[] = 'No value has been supplied for encryption'; return; } // if while (strlen($source) < $sourcelen) { $source .= ' '; } // while $target = NULL; $factor2 = 0; for ($i = 0; $i < strlen($source); $i++) { $char1 = substr($source, $i, 1); $num1 = strpos($this->scramble1, $char1); if ($num1 === false) { $this->errors[] = "Source string contains an invalid character ($char1)"; return; } // if $adj = $this->_applyFudgeFactor($fudgefactor); $factor1 = $factor2 + $adj; $num2 = round($factor1) + $num1; // generate offset for $scramble2 $num2 = $this->_checkRange($num2); // check range $factor2 = $factor1 + $num2; // accumulate in $factor $char2 = substr($this->scramble2, $num2, 1); $target .= $char2; } // for return $target; } // encrypt function _convertKey ($key) { if (empty($key)) { $this->errors[] = 'No value has been supplied for the encryption key'; return; } // if $array[] = strlen($key); $tot = 0; for ($i = 0; $i < strlen($key); $i++) { $char = substr($key, $i, 1); $num = strpos($this->scramble1, $char); if ($num === false) { $this->errors[] = "Key contains an invalid character ($char)"; return; } // if $array[] = $num; $tot = $tot + $num; } // for $array[] = $tot; return $array; } // _convertKey function _applyFudgeFactor (&$fudgefactor) { $fudge = array_shift($fudgefactor); $fudge = $fudge + $this->adj; $fudgefactor[] = $fudge; if (!empty($this->mod)) { // if modifier has been supplied if ($fudge % $this->mod == 0) { // if it is divisible by modifier $fudge = $fudge * -1; // reverse then sign } // if } // if return $fudge; } // _applyFudgeFactor function _checkRange ($num) { $limit = strlen($this->scramble1)-1; while ($num > $limit) { $num = $num - $limit; } // while while ($num < 0) { $num = $num + $limit; } // while return $num; } // _checkRange function decrypt ($key, $source) { $this->errors = array(); $fudgefactor = $this->_convertKey($key); if ($this->errors) return; if (empty($source)) { $this->errors[] = 'No value has been supplied for decryption'; return; } // if $target = NULL; $factor2 = 0; for ($i = 0; $i < strlen($source); $i++) { $char2 = substr($source, $i, 1); $num2 = strpos($this->scramble2, $char2); if ($num2 === false) { $this->errors[] = "Source string contains an invalid character ($char2)"; return; } // if if ($num2 == 0) { // use the last occurrence of this letter, not the first $num2 = strlen($this->scramble1)-1; } // if $adj = $this->_applyFudgeFactor($fudgefactor); $factor1 = $factor2 + $adj; $num1 = round($factor1*-1) + $num2; // generate offset for $scramble1 $num1 = $this->_checkRange($num1); // check range $factor2 = $factor1 + $num2; // accumulate in $factor2 $char1 = substr($this->scramble1, $num1, 1); $target .= $char1; } // for return rtrim($target); } // decrypt } $crypt = new encryption_class; echo $crypt->decrypt("ptufednkji", "bN,%vZ+R,rg/\9"); ?>

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.00617.00
8.3.50.0110.00416.49
8.3.40.0110.00318.84
8.3.30.0150.00018.63
8.3.20.0050.00220.34
8.3.10.0030.00621.89
8.3.00.0030.00523.49
8.2.180.0110.00725.92
8.2.170.0090.00622.96
8.2.160.0140.00320.47
8.2.150.0030.00524.18
8.2.140.0000.00824.66
8.2.130.0030.00619.76
8.2.120.0040.00426.35
8.2.110.0030.00720.63
8.2.100.0040.00818.16
8.2.90.0050.00319.31
8.2.80.0000.00818.15
8.2.70.0000.00917.88
8.2.60.0030.00618.16
8.2.50.0040.00418.07
8.2.40.0050.00522.21
8.2.30.0000.00719.50
8.2.20.0040.00417.81
8.2.10.0050.00318.09
8.2.00.0080.00018.09
8.1.280.0060.00925.92
8.1.270.0000.00920.38
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0030.00622.17
8.1.230.0080.00419.22
8.1.220.0000.00917.74
8.1.210.0080.00018.77
8.1.200.0030.00617.48
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0080.00018.71
8.1.160.0050.00320.79
8.1.150.0080.00018.98
8.1.140.0040.00419.62
8.1.130.0030.00317.79
8.1.120.0000.00717.41
8.1.110.0040.00417.44
8.1.100.0040.00417.50
8.1.90.0070.00017.42
8.1.80.0000.00817.46
8.1.70.0040.00417.48
8.1.60.0050.00217.59
8.1.50.0080.00317.61
8.1.40.0050.00317.59
8.1.30.0090.00017.68
8.1.20.0030.00517.63
8.1.10.0000.00717.69
8.1.00.0000.00717.66
8.0.300.0050.00518.77
8.0.290.0070.00016.88
8.0.280.0030.00618.57
8.0.270.0000.00717.34
8.0.260.0030.00318.72
8.0.250.0070.00316.88
8.0.240.0000.00717.07
8.0.230.0050.00217.05
8.0.220.0080.00017.04
8.0.210.0040.00417.02
8.0.200.0030.00317.05
8.0.190.0000.00716.98
8.0.180.0030.00617.02
8.0.170.0030.00616.91
8.0.160.0000.00817.02
8.0.150.0000.00816.87
8.0.140.0050.00216.98
8.0.130.0070.00013.48
8.0.120.0060.00316.92
8.0.110.0050.00216.91
8.0.100.0040.00416.88
8.0.90.0040.00417.00
8.0.80.0130.00816.92
8.0.70.0040.00416.80
8.0.60.0000.00717.02
8.0.50.0000.00716.78
8.0.30.0130.00417.05
8.0.20.0110.00817.40
8.0.10.0000.00816.94
8.0.00.0100.00716.87
7.4.330.0050.00016.97
7.4.320.0030.00316.52
7.4.300.0000.00716.66
7.4.290.0040.00416.66
7.4.280.0030.00716.68
7.4.270.0000.00716.82
7.4.260.0000.00716.63
7.4.250.0050.00316.73
7.4.240.0030.00516.68
7.4.230.0040.00416.86
7.4.220.0060.01916.66
7.4.210.0110.00416.84
7.4.200.0000.00716.79
7.4.160.0070.01016.73
7.4.150.0110.00717.40
7.4.140.0100.01417.86
7.4.130.0150.00616.64
7.4.120.0110.00616.74
7.4.110.0090.00916.87
7.4.100.0130.01016.81
7.4.90.0120.00616.77
7.4.80.0110.00819.39
7.4.70.0110.00616.70
7.4.60.0180.00016.76
7.4.50.0070.00316.71
7.4.40.0110.00616.39
7.4.30.0110.01116.77
7.4.00.0030.00915.16
7.3.330.0050.00013.56
7.3.320.0040.00413.40
7.3.310.0080.00016.57
7.3.300.0000.00716.57
7.3.290.0060.01316.57
7.3.280.0080.00916.59
7.3.270.0030.01417.40
7.3.260.0090.00916.79
7.3.250.0090.00816.64
7.3.240.0070.01016.77
7.3.230.0090.00916.79
7.3.210.0100.00716.82
7.3.200.0060.01219.39
7.3.190.0100.01016.57
7.3.180.0060.01216.64
7.3.170.0090.01216.56
7.3.160.0140.00416.67
7.3.120.0030.01215.14
7.3.110.0100.00615.07
7.3.100.0000.01414.96
7.3.90.0070.00714.75
7.3.80.0050.00514.95
7.3.70.0060.00914.98
7.3.60.0030.01014.68
7.3.50.0060.00915.04
7.3.40.0030.01015.01
7.3.30.0000.01014.93
7.3.20.0060.00916.70
7.3.10.0050.00516.79
7.3.00.0060.00616.47
7.2.330.0060.01216.63
7.2.320.0130.00316.98
7.2.310.0130.00316.81
7.2.300.0090.00916.56
7.2.290.0070.01016.87
7.2.240.0040.00815.39
7.2.230.0030.01515.29
7.2.220.0100.00315.29
7.2.210.0060.00614.80
7.2.200.0060.00915.13
7.2.190.0070.00714.86
7.2.180.0030.01015.04
7.2.170.0030.01315.19
7.2.160.0070.00715.23
7.2.150.0000.01516.99
7.2.140.0080.00816.69
7.2.130.0060.00316.93
7.2.120.0040.00716.90
7.2.110.0030.01016.80
7.2.100.0090.00616.97
7.2.90.0070.01317.09
7.2.80.0130.00317.05
7.2.70.0090.00616.86
7.2.60.0060.00716.97
7.2.50.0030.00716.92
7.2.40.0000.01516.99
7.2.30.0040.00717.00
7.2.20.0000.01317.01
7.2.10.0100.00416.92
7.2.00.0070.00717.97
7.1.330.0030.01015.98
7.1.320.0070.01015.95
7.1.310.0000.01415.92
7.1.300.0000.00915.64
7.1.290.0060.00315.69
7.1.280.0100.00715.63
7.1.270.0040.00415.66
7.1.260.0120.00315.97
7.1.250.0040.01115.75
7.1.200.0040.00815.83
7.1.100.0000.01418.06
7.1.70.0040.00417.09
7.1.60.0120.00319.30
7.1.50.0030.02417.06
7.1.00.0070.07322.51
7.0.200.0070.00316.95
7.0.60.0200.08021.74
7.0.50.0100.07717.92
7.0.40.0030.07020.04
7.0.30.0170.04720.06
7.0.20.0230.08720.30
7.0.10.0130.08020.25
7.0.00.0030.06320.22
5.6.280.0000.07021.16
5.6.210.0100.07020.51
5.6.200.0030.06018.29
5.6.190.0070.09020.61
5.6.180.0500.06720.51
5.6.170.0270.08020.46
5.6.160.0070.06720.56
5.6.150.0170.04018.16
5.6.140.0100.07718.19
5.6.130.0100.05718.25
5.6.120.0100.06721.04
5.6.110.0070.08321.18
5.6.100.0100.08021.01
5.6.90.0170.07321.09
5.6.80.0000.04320.42
5.5.350.0070.07020.44
5.5.340.0130.07017.99
5.5.330.0030.07320.37
5.5.320.0670.05320.37
5.5.310.0200.05020.47
5.5.300.0100.07717.96
5.5.290.0030.04018.06
5.5.280.0070.04020.83
5.5.270.0070.05020.82
5.5.260.0100.07320.93
5.5.250.0070.07320.64
5.5.240.0100.04320.15

preferences:
75.53 ms | 400 KiB | 5 Q