Skip to content

Instantly share code, notes, and snippets.

@lukasklein
Created November 4, 2012 16:01
Show Gist options
  • Save lukasklein/4012387 to your computer and use it in GitHub Desktop.
Save lukasklein/4012387 to your computer and use it in GitHub Desktop.
One Time Pad PHP
<?php
function otp($text, $key) {
$text_chunks = explode(' ', $text);
$key_chunks = explode(' ', $key);
for($i = 0; $i < count($text_chunks); $i++) {
echo chr(hexdec($text_chunks[$i]) ^ hexdec($key_chunks[$i]));
}
}
otp('1C 07 7F 6F A7 86 A6 E9 E5 75 78 A9 73 B9 17 2F D6 00 25 9F B4 86 16 07 4D 07 0F 98 0F AB 0F 6C 11 10 0F 34 21 FD 2D 69 B3 0D 7F 21 96 3C', '4F 4E 3A 4F F4 C5 EE A0 A0 26 2B EC 3D 99 53 66 93 20 67 CD FD C3 50 54 0E 4F 4E DE 5B EE 41 4C 55 45 5D 77 69 DD 68 20 FD 2D 2D 6E DE 6E');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment