Advertisement
cd62131

XOR

Feb 22nd, 2014
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. <?php
  2. if (PHP_SAPI !== 'cli') exit();
  3. if ($argc !== 3 || in_array($argv[1], ['--help', '-h'])) {
  4.   echo "Usage: {$argv[0]} INFILE OUTFILE", PHP_EOL;
  5.   exit();
  6. }
  7. $in = fopen($argv[1], 'r');
  8. $out = fopen($argv[2], 'w');
  9. $m = 0x80;
  10. for ( ; false !== ($c = fgetc($in)); $m++) {
  11.   if ($m == 0xff) $m = 0x80;
  12.   fwrite($out, chr(ord($c) ^ $m));
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement