3v4l.org

run code in 300+ PHP versions simultaneously
<?php function strToHex($string){ $hex = ''; for ($i=0; $i<strlen($string); $i++){ $ord = ord($string[$i]); $hexCode = dechex($ord); $hex .= substr('0'.$hexCode, -2); } return strToUpper($hex); } function hexToStr($hex){ $string=''; for ($i=0; $i < strlen($hex)-1; $i+=2){ $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string; } function fxor($key, $text){ // Our output text $outText = ''; // Iterate through each character for($i=0;$i<strlen($text);) // Dont need to increment here { for($j=0;$j<strlen($key);$j++,$i++) { $outText .= $text{$i} ^ $key{$j}; } } return $outText; } $ciphertext_base64 = 'sf7PwIfhqofFlKAIgYMKEbExOoVzSj9A0KDwKMJY62k%3D'; $ciphertextHex = strToHex($ciphertext_base64); echo "ciipher hex: " . $ciphertextHex . "\n"; $hexToBase = hexToStr($ciphertextHex); echo "hexToBase: " . $hexToBase . "\n"; echo "ciher base: " . $ciphertext_base64 . "\n"; $ciphertext_dec = base64_decode($ciphertext_base64); # --- DECRYPTION --- echo "cipher text dec: " . $ciphertext_dec . "\n"; echo "ciher dec in hex" . strToHex($ciphertext_dec) . "\n"; $iv = substr($ciphertext_dec,0, 16); $res = substr($ciphertext_dec, 16, strlen($ciphertext_dec)-16); echo "---iv: " . $iv . "\n"; echo "---res: " . $res . "\n"; # retrieves the IV, iv_size should be created using mcrypt_get_iv_size() $iv_dec = substr($ciphertext_dec, 0, 16); echo "iv dec: " . $iv_dec . "\n"; # retrieves the cipher text (everything except the $iv_size in the front) $ciphertext_dec = substr($ciphertext_dec, 16); echo "on the right: " . $ciphertext_dec . "\n"; $ivHex = strToHex($iv_dec); echo "change string to hex (iv): " .$ivHex . "\n"; echo "w druga manke: " . hexToStr($ivHex) . "\n"; $onRightHex = strToHex($ciphertext_dec); echo "onRight in hex: " . $onRightHex . "\n"; echo "w druga manke: " . hexToStr( strToHex($ciphertext_dec) ) . "\n"; $testHex = strToHex('id=1'); $adHex = strToHex('id=2'); echo "testHex: " . $testHex . "\n"; echo "adHex: " . $adHex . "\n"; $xta = strToUpper( dechex(hexdec($testHex) ^ hexdec($adHex)) ); $myXor = fxor($testHex, $adHex ); echo "xta: " . $xta . "\n"; echo "myXor: " . $myXor . "\n"; $ivHex2 = substr($ivHex, 16, 32); $ivHex1 = substr($ivHex, 0, 16); echo "ivHex2: " . $ivHex2 . "\n"; echo "ivHex1: " . $ivHex1 . "\n"; $xivxta = strToUpper( dechex(hexdec($xta) ^ hexdec($ivHex2)) ); echo "xivxta: " . $xivxta . "\n"; $cmpHex = $ivHex1 . $xivxta . $onRightHex; echo "cmpHex: " . $cmpHex . "\n"; $cmpStr = hexToStr($cmpHex); echo "cmpStr: " . $cmpStr . "\n"; $cmpB = base64_encode($cmpStr); echo "cmpB: " . $cmpB; ?>

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.4.20.0040.01417.91
8.4.10.0040.01219.64
8.3.150.0040.01417.09
8.3.140.0150.00416.86
8.3.130.0050.00318.31
8.3.120.0040.00418.85
8.3.110.0040.00720.94
8.3.100.0070.00324.06
8.3.90.0120.00626.77
8.3.80.0080.00017.97
8.3.70.0150.00018.25
8.3.60.0160.00018.30
8.3.50.0120.00822.01
8.3.40.0120.00318.71
8.3.30.0040.01118.68
8.3.20.0000.00721.91
8.3.10.0000.00821.73
8.3.00.0070.00021.93
8.2.260.0120.00316.75
8.2.250.0040.00416.79
8.2.240.0050.00518.60
8.2.230.0060.00322.58
8.2.220.0070.01037.54
8.2.210.0050.00526.77
8.2.200.0100.00016.50
8.2.190.0110.00716.88
8.2.180.0140.00718.42
8.2.170.0110.00722.96
8.2.160.0070.00722.13
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00726.16
8.2.120.0040.00421.00
8.2.110.0030.00621.12
8.2.100.0120.00018.03
8.2.90.0080.00018.93
8.2.80.0040.00417.97
8.2.70.0060.00317.38
8.2.60.0040.00417.80
8.2.50.0000.00818.10
8.2.40.0000.00720.39
8.2.30.0000.00719.21
8.2.20.0000.00717.83
8.2.10.0040.00418.00
8.2.00.0040.00417.63
8.1.310.0040.00418.38
8.1.300.0080.00017.91
8.1.290.0080.00030.84
8.1.280.0090.00625.92
8.1.270.0000.00824.02
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0000.01019.09
8.1.230.0040.00820.30
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0030.00617.23
8.1.190.0040.00417.10
8.1.180.0030.00618.10
8.1.170.0050.00318.59
8.1.160.0000.00818.75
8.1.150.0070.00022.10
8.1.140.0050.00219.53
8.1.130.0000.00819.00
8.1.120.0080.00017.26
8.1.110.0000.00717.37
8.1.100.0050.00217.37
8.1.90.0050.00317.39
8.1.80.0000.00817.25
8.1.70.0040.00417.25
8.1.60.0050.00317.38
8.1.50.0000.00717.39
8.1.40.0050.00317.45
8.1.30.0050.00317.59
8.1.20.0030.00617.60
8.1.10.0050.00317.38
8.1.00.0000.00817.22
8.0.300.0000.00818.95
8.0.290.0060.00316.63
8.0.280.0070.00018.38
8.0.270.0080.00017.18
8.0.260.0030.00317.10
8.0.250.0030.00316.83
8.0.240.0070.00016.91
8.0.230.0000.00716.84
8.0.220.0040.00416.86
8.0.210.0000.00716.80
8.0.200.0000.00816.96
8.0.190.0040.00416.98
8.0.180.0030.00516.89
8.0.170.0030.00516.87
8.0.160.0050.00316.77
8.0.150.0040.00416.82
8.0.140.0070.00016.84
8.0.130.0030.00313.33
8.0.120.0040.00416.75
8.0.110.0000.00716.82
8.0.100.0000.00816.80
8.0.90.0050.00216.89
8.0.80.0070.00716.86
8.0.70.0030.00516.64
8.0.60.0050.00316.98
8.0.50.0070.00016.90
8.0.30.0070.01116.96
8.0.20.0120.00717.40
8.0.10.0040.00416.77
8.0.00.0100.00716.75
7.4.330.0030.00315.55
7.4.320.0070.00016.66
7.4.300.0060.00016.76
7.4.290.0030.00316.64
7.4.280.0030.00616.71
7.4.270.0000.00716.64
7.4.260.0070.00016.62
7.4.250.0040.00416.59
7.4.240.0050.00316.59
7.4.230.0000.00716.48
7.4.220.0190.00016.65
7.4.210.0150.00016.80
7.4.200.0000.00716.83
7.4.160.0100.00516.75
7.4.150.0150.00317.40
7.4.140.0120.00817.86
7.4.130.0110.00916.67
7.4.120.0060.01316.65
7.4.110.0100.00716.76
7.4.100.0110.01216.63
7.4.90.0110.00616.65
7.4.80.0100.00719.39
7.4.70.0110.00716.66
7.4.60.0040.01316.74
7.4.50.0110.00316.90
7.4.40.0090.00916.53
7.4.30.0050.01316.68
7.4.00.0060.01115.19
7.3.330.0030.00313.27
7.3.320.0030.00313.49
7.3.310.0040.00416.53
7.3.300.0030.00316.36
7.3.290.0070.00816.52
7.3.280.0070.00916.47
7.3.270.0090.00917.40
7.3.260.0090.01016.51
7.3.250.0090.00916.62
7.3.240.0080.01016.61
7.3.230.0140.00716.54
7.3.210.0060.01216.66
7.3.200.0070.01116.47
7.3.190.0160.00316.60
7.3.180.0110.00516.59
7.3.170.0180.00416.53
7.3.160.0110.00516.49
7.3.120.0090.00914.94
7.3.110.0090.00914.92
7.3.100.0000.01315.03
7.3.90.0090.00015.24
7.3.80.0100.00714.94
7.3.70.0070.00714.88
7.3.60.0130.00314.70
7.3.50.0030.01315.03
7.3.40.0030.01215.04
7.3.30.0040.00715.00
7.3.20.0030.00716.80
7.3.10.0050.01116.70
7.3.00.0080.01116.82
7.2.330.0100.00716.67
7.2.320.0090.00916.66
7.2.310.0140.00316.86
7.2.300.0060.01316.76
7.2.290.0100.00716.62
7.2.250.0070.01415.44
7.2.240.0030.01715.13
7.2.230.0130.00315.32
7.2.220.0060.00915.13
7.2.210.0000.01814.95
7.2.200.0030.00915.14
7.2.190.0030.01314.98
7.2.180.0090.00915.43
7.2.170.0090.00015.05
7.2.130.0060.00616.82
7.2.120.0080.00816.84
7.2.110.0140.00016.93
7.2.100.0080.00816.73
7.2.90.0170.00316.88
7.2.80.0040.00816.68
7.2.70.0090.00616.83
7.2.60.0110.00816.78
7.2.50.0190.00016.69
7.2.40.0000.01116.95
7.2.30.0070.01116.91
7.2.20.0080.00616.87
7.2.10.0060.00616.98
7.2.00.0030.01016.65
7.1.330.0030.01216.00
7.1.320.0030.01015.91
7.1.310.0000.01515.91
7.1.300.0090.00615.79
7.1.290.0060.00915.98
7.1.280.0100.00416.09
7.1.270.0030.01015.67
7.1.260.0080.00815.95
7.1.250.0040.01115.45
7.1.70.0140.00317.10
7.1.60.0310.00415.32
7.1.10.0200.05322.24
7.1.00.0170.05322.39
7.0.200.0030.01416.76
7.0.150.0070.06021.89
7.0.140.0130.05321.87
7.0.130.0130.05322.05
7.0.120.0070.06321.92
7.0.110.0100.06321.92
7.0.100.0130.05721.91
7.0.90.0000.07021.86
7.0.80.0000.06722.07
7.0.70.0170.05321.97
7.0.60.0100.07721.89
7.0.50.0070.05722.04
7.0.40.0130.05321.96
7.0.30.0270.04021.86
7.0.20.0030.06022.01
7.0.10.0100.06021.93
7.0.00.0100.05721.88

preferences:
75.91 ms | 403 KiB | 5 Q