3v4l.org

run code in 300+ PHP versions simultaneously
<?php function OTP($input, $pad) { $inputlen = strlen($input); $padlen = strlen($pad); $inputbytes = unpack("C*", $input); //Pack C* will convert a string into a byte array, such as 'abc' to Array(0x61, 0x62, 0x63) $padbytes = unpack("C*", $pad); $output = ""; for($i = 0; $i < $inputlen; $i++) //Loop through the input string $output .= chr($inputbytes[$i + 1] ^ $padbytes[$i % $padlen + 1]); return $output; } $result = OTP("This is a long sentence", "Abc"); var_dump(unpack("C*", $result)); var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
array(23) { [1]=> int(21) [2]=> int(10) [3]=> int(10) [4]=> int(50) [5]=> int(66) [6]=> int(10) [7]=> int(50) [8]=> int(66) [9]=> int(2) [10]=> int(97) [11]=> int(14) [12]=> int(12) [13]=> int(47) [14]=> int(5) [15]=> int(67) [16]=> int(50) [17]=> int(7) [18]=> int(13) [19]=> int(53) [20]=> int(7) [21]=> int(13) [22]=> int(34) [23]=> int(7) } string(23) " 2B 2Ba /C2 5 ""

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.73 ms | 402 KiB | 8 Q