3 function bin_trim ($bin) {
5 $x = (8 - strlen($bin));
15 function xor_bytes ($bina, $binb) {
19 if ($bina[$x-1] XOR $binb[$x-1])
20 { $bin = ( 1 . $bin ); } else { $bin = ( 0 . $bin ); }
26 //CODE/////////////////////////////////////////////////////
28 $message = "POKUS CISLO JEDNA DVA TRI";
29 $message = ")-#&O&$6(.:E/-:H&#&*H--$.";
30 $message = "message MESSAGE toto je pokus 545446653\9aèøèø\9eøýá ahoj";
31 //$message = "%-\e\14) -g&\ 2\11\10\12\ 23N\1f%\1d\15Z\8b\98\17F\97\83\9d\8eÍÜ\ 4\fÝA×CÔI{¼ªÝÌÛ̸Õe\e\89\15\93";
32 $message = implode("", file("cypher.txt"));
33 $code = "HHhgHGHGkGBCSEvnkJizzáý76øèèýíé09éuáuázáTR54E4E4Ezázùdlmkdsfh-";
35 //print "Pocet parametru: " . $argc . "\n";
36 //foreach($argv as $param)
37 // print $param . "\n";
39 //if($argc != 3) { die("Usage: xor.php secretcode in.txt > out.txt\n"); }
41 //echo($argv[0]."\n");
43 //$message = implode("", file($argv[2]));
44 $message = "&.(\fh\1c(-fKH-)!F\ 5
47 $code = "gfgFHJghGjhghjfVHGhjGhjGvvXfgdTGfHgHfgFhfVBGcftDtFzdfdgfgf6ztFzF";
51 //Message to bin array:
54 while($i < strlen($message)) {
55 $message_bin = ($message_bin . bin_trim(base_convert(ord($message[$i]),10,2)). "\n " );
58 //echo ($message_bin."\n\n"); //Debug
60 $message_bin = explode(" ",$message_bin);
65 while ($i < strlen($message)) {
67 $char = $message_bin[$i];
68 $cchar = bin_trim( base_convert( ord($code[$y]), 10, 2) );
70 //echo($code[$y]); //Debug
71 //echo($cchar."\n"); //Debug
72 //echo($char); //Debug
74 $message[$i] = chr( base_convert(xor_bytes($char, $cchar),2,10 ));
77 if ($y >= strlen($code)) { $y = 0; }
This page took 1.751343 seconds and 4 git commands to generate.