= ord(' ') && $ch <= ord('z') && $key[$i%20] != "\x00") { echo chr($ch); } else { if ($ch == ord("\n")) echo '¬'; else echo "*"; } } echo "\n\n> "; } while (1) { show($s, $key); # x y char $cmd = trim(fgets(STDIN), "\r\n\t "); echo "\n"; if ($cmd == "save") { file_put_contents("key.bin", $key); file_put_contents("dump.cp", decrypt($s, $key)); echo "Dump and key saved!\n\n"; continue; } $parts = explode(" ", $cmd); $y = intval($parts[0]); $x = intval($parts[1]); $pos = $x+$y*20; $ch = (($parts[2] == "\\n") ? "\n" : $parts[2]); if ($y < 0 or $y > (strlen($s)/20)+1) { echo "bad y\n\n"; continue; } if ($x < 0 or $x > 19 or $pos >= strlen($s)) { echo "bad x\n\n"; continue; } $key[$x] = chr(ord($s[$pos])^ord($ch)); } ?>