$coString = gzcompress($it, 9); // test if compressed can be recompressed echo '<b>compressioned scrambled size: ' . strlen($coString) . '</b><br>'; } // loop through scramble keys looking for best compression // next joint the two files and convet it back to decimal as well as // add the 1st byte as the scramblekey followed by a long word 4 bytes (x00000000) of the size of part 0 $nf = gzuncompress($coString); // uncompress echo 'uncompressioned scrambled size: ' . strlen($nf) . '<br>'; // convert it back to binary for ($c = 0; $c < $filesize; $c++) { // cyctle through the whole file doing a byte at a time. $byte = $nf[$c]; // get byte to process $nbb .= byte2bin($byte); // get binary represintation } echo '<br>bits to unscramble<br>' . $nbb . '<br>'; // decode file $pa = ''; // store decode file bin version $pb = ''; // string version $pac = 0; // index into part a and b $pbc = 0; $sizeofbin = strlen($nbb); for ($ii = 0; $ii < $sizeofbin / 8; $ii++) { // cyctle through the whole file doing a byte at a time. for ($i = 0; $i <= 7; $i++) {
$c++; $bits = byte2bin($thebytes[$c]); $umm1 = $bits[2] . $bits[3] . $bits[4] . $bits[5] . $bits[6] . $bits[7]; $c++; $bits = byte2bin($thebytes[$c]); $umm2 = $bits[2] . $bits[3] . $bits[4] . $bits[5] . $bits[6] . $bits[7]; $umm = $umm0 . $umm1 . $umm2; echo '&#' . bindec($umm) . ';'; } else { if ($bits[4] == 0) { // four bytes $umm0 = $bits[5] . $bits[6] . $bits[7]; $c++; $bits = byte2bin($thebytes[$c]); $umm1 = $bits[2] . $bits[3] . $bits[4] . $bits[5] . $bits[6] . $bits[7]; $c++; $bits = byte2bin($thebytes[$c]); $umm2 = $bits[2] . $bits[3] . $bits[4] . $bits[5] . $bits[6] . $bits[7]; $c++; $bits = byte2bin($thebytes[$c]); $umm3 = $bits[2] . $bits[3] . $bits[4] . $bits[5] . $bits[6] . $bits[7]; $umm = $umm0 . $umm1 . $umm2 . $umm3; echo '&#' . bindec($umm) . ';'; } } } } } ?> </pre>
// bytes to scramble, this will be the compress file. echo $thebytes . '<br>'; echo '<br>Orgional file size ' . strlen($thebytes) . '<br>'; $tb = str_split($thebytes); // convert input file into an array of bytes // need to add for loop to cycle through split key (1-254) or just one key as this is the test area before working with compressed files. $scramkey = 102; // scramble key set $skey = dec2bin($scramkey); // convert to binary echo $skey[0] . $skey[1] . $skey[2] . $skey[3] . $skey[4] . $skey[5] . $skey[6] . $skey[7] . ' scramble skey<br>'; $P0 = ''; $P1 = ''; foreach ($tb as $byte) { // loop through file byte by byte $bb = byte2bin($byte); // make chars binary // $bb= dec2bin($byte); // make byte binary // if key bit = 0 put bb bit in part 0 else put it into part 1 for ($i = 0; $i <= 7; $i++) { // process the byte bit by bit if ($skey[$i] == '0') { $P0 .= $bb[$i]; } else { $P1 .= $bb[$i]; } } } echo $P0 . ' p0<br>'; echo $P1 . ' p1<br>'; $p0len = strlen($P0);