Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $map = array(
- "ever 6" => 'L',
- "
- I just wanna J9Z
- Gotta U9understand
- B" => 'C',
- "279up2let 9down2run arouHaHdesert you2U9cry2say goodbye2Ja lie aHhurt you"=>'B',
- "
- Never 6" => '2',
- "how I'm feelX"=>'Z',
- "
- We'vePn eachRfor so longQr hearTachX butQ'reKshy to say it
- Inside we bothP whaTgoX on
- WePSgaVaHwe're 6play it"=>'3',
- "8, 79up)"=>'4',
- "8)
- N1, n1
- (Give 9up)"=>'5',
- "ever 6give" => '1',
- 'gonna ' => '6',
- 'give ' => '7',
- "
- (Ooh" => '8',
- "you " => "9",
- "nd "=> 'H',
- 'tell '=>'J',
- ' too '=>'K',
- ' know'=>'P',
- "
- You"=>"Q",
- ' other ' => 'R',
- ' the ' => "S",
- "t's been " => "T",
- "make "=>'U',
- "me "=>'V',
- 'ing' => "X"
- );
- $c = str_split(implode(array_values($map)));
- $r = explode(M,implode('M',array_keys($map)));
- //Flip the arrays
- $c = array_reverse($c);
- $r = array_reverse($r);
- print_r($c);
- function encode($input){
- global $c,$r;
- $input=str_replace($r,$c,$input);
- return $input;
- }
- function decode($input){
- global $c,$r;
- $input=str_replace($c,$r,$input);
- return $input;
- }
- function verify_match($real,$decoded){
- return ($real == $decoded);
- }
- $real_lyrics = file_get_contents('lyrics.txt');
- $encoded = encode($real_lyrics);
- print "\r\nENCODE------\r\n";
- print substr($encoded,0,150);
- $fh = fopen('compressed.txt','w');
- fwrite($fh,$encoded);
- fclose($fh);
- //Flip the arrays
- $c = array_reverse($c);
- $r = array_reverse($r);
- $compressed = file_get_contents('compressed.txt');
- $program = '<?=str_replace(str_split('.implode(array_values($map)).'),explode(M,"'.implode('M',array_keys($map)).'"),"'.$compressed.'");';
- $fh = fopen('program.php','w');
- fwrite($fh,$program);
- fclose($fh);
- print "\r\nDECODE------\r\n";
- $decoded = decode($encoded);
- print $decoded;
- print "\r\nByte count?\r\n";
- print strlen($program);
- print "\r\nIs decoded the same as original?\r\n";
- var_dump(verify_match($real_lyrics,$decoded));
- /*
- print "\r\nR sequence ----\r\n------\r\n";
- print implode('M',array_reverse(array_keys($map)));
- print "\r\nC sequence ----\r\n------\r\n";
- print implode(array_reverse(array_values($map)));
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement