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 = 'eqnwLe9HHCzgN9TcOuzYbGRseWIxgmcaNEXu9%252BCws1U%253D'; $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; echo "---res: " . $res; # 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('test'); $adHex = strToHex('admin'); 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; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/auQMKM on line 30
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/auQMKM on line 30 Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/auQMKM on line 30 ciipher hex: 65716E774C65394848437A674E3954634F757A596247527365574978676D63614E45587539253235324243777331552532353344 hexToBase: eqnwLe9HHCzgN9TcOuzYbGRseWIxgmcaNEXu9%252BCws1U%253D ciher base: eqnwLe9HHCzgN9TcOuzYbGRseWIxgmcaNEXu9%252BCws1U%253D cipher text dec: z��-�G,�7��:��ldlyb1�g4E�nv,,�M�� ciher dec in hex7AA9F02DEF471C2CE037D4DC3AECD86C646C79623182671A3445EEF76E76042C2CD54DB9DC ---iv: z��-�G,�7��:��l---res: dlyb1�g4E�nv,,�M��iv dec: z��-�G,�7��:��l on the right: dlyb1�g4E�nv,,�M�� change string to hex (iv): 7AA9F02DEF471C2CE037D4DC3AECD86C w druga manke: z��-�G,�7��:��l onRight in hex: 646C79623182671A3445EEF76E76042C2CD54DB9DC w druga manke: dlyb1�g4E�nv,,�M�� testHex: 74657374 adHex: 61646D696E xta: 6110081A1A ivHex2: E037D4DC3AECD86C ivHex1: 7AA9F02DEF471C2C xivxta: E037D4BD2AE4C21A cmpHex: 7AA9F02DEF471C2CE037D4BD2AE4C21A646C79623182671A3445EEF76E76042C2CD54DB9DC cmpStr: z��-�G,�7Խ*��dlyb1�g4E�nv,,�M�� cmpB: eqnwLe9HHCzgN9S9KuTCGmRseWIxgmcaNEXu9252BCws1U253A==
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
ciipher hex: 65716E774C65394848437A674E3954634F757A596247527365574978676D63614E45587539253235324243777331552532353344 hexToBase: eqnwLe9HHCzgN9TcOuzYbGRseWIxgmcaNEXu9%252BCws1U%253D ciher base: eqnwLe9HHCzgN9TcOuzYbGRseWIxgmcaNEXu9%252BCws1U%253D cipher text dec: z��-�G,�7��:��ldlyb1�g4E�nv,,�M�� ciher dec in hex7AA9F02DEF471C2CE037D4DC3AECD86C646C79623182671A3445EEF76E76042C2CD54DB9DC ---iv: z��-�G,�7��:��l---res: dlyb1�g4E�nv,,�M��iv dec: z��-�G,�7��:��l on the right: dlyb1�g4E�nv,,�M�� change string to hex (iv): 7AA9F02DEF471C2CE037D4DC3AECD86C w druga manke: z��-�G,�7��:��l onRight in hex: 646C79623182671A3445EEF76E76042C2CD54DB9DC w druga manke: dlyb1�g4E�nv,,�M�� testHex: 74657374 adHex: 61646D696E xta: 6110081A1A ivHex2: E037D4DC3AECD86C ivHex1: 7AA9F02DEF471C2C xivxta: E037D4BD2AE4C21A cmpHex: 7AA9F02DEF471C2CE037D4BD2AE4C21A646C79623182671A3445EEF76E76042C2CD54DB9DC cmpStr: z��-�G,�7Խ*��dlyb1�g4E�nv,,�M�� cmpB: eqnwLe9HHCzgN9S9KuTCGmRseWIxgmcaNEXu9252BCws1U253A==

preferences:
175.08 ms | 404 KiB | 180 Q