#!/usr/bin/perl # xor2.pl - Don Yang (uguu.org) # # Encode source by decomposing each character into XOR pairs. # # 12/23/07 use strict; my $code = q{ $l = 23 - 2 * ($a = sin(($c = (time() % 100) / 50) * atan2(0, -1))); $p = 10.5 + $a; $q = 6.5 - $a; if( $c < 1 ) { $s = 56 - 33 * $c; $x = 2 * $c - 1; $t = 11 + $x * $x * 7; } else { $s = 23 + 33 * ($c - 1); $t = 18; } for($y = 0; $y < 24; $y++) { $v = ($y - $t) / ($y < $t ? $p : $q); for($x = 0; $x < 79; $x++) { $u = ($x - $s) / $l; $c = $x - int($s); $z .= chr ( $y == int($t + $q) && abs($x - $s) < 10 ? 33 : ( $u * $u + $v * $v > 1 || ($y > $t - 5 - 2 * $a && $y <= $t - 2 - 2 * $a && !($c + 6 && $c && $c + 5 && $c - 1)) ? 32 : 33 ) ); } $z .= "\n"; } $c = ($z =~ y/!/x/); $n = '$n=q{' . $n . '#'x($c - length($n) - 26) . '};$n=~s/\s//g;eval$n;'; $y = 0; foreach $x ($z =~ /./gs) { print 'x' eq $x ? substr($n, $y++, 1) : $x; } }; $code =~ s/\s//g; print "code =\n$code\n"; # Generate dictionary my %dict; for(my $i = 33; $i < 127; $i++) { next if chr($i) !~ /[`:;#%&\[\]]/; for(my $j = 33; $j < 127; $j++) { next if chr($j) =~ /['[:alpha:]]/; push @{$dict{$i ^ $j}}, chr($i) . chr($j); } } print "dict =\n"; for(my $i = 33; $i < 127; $i++) { next unless exists $dict{$i}; print "$i ="; print " $_" foreach @{$dict{$i}}; print "\n"; } # Encode source code pairs my $p = ''; my $q = ''; my $d = 0; foreach my $c (unpack 'C*', $code) { # See if we can encode this character using "dango" or "DANGO" my $p0 = substr("Dango", $d, 1); my $q0 = chr($c) ^ $p0; if( ord($q0) > 32 && ord($q0) < 127 && $q0 ne "'" ) { $d = ($d + 1) % 5; $p .= $p0; $q .= $q0; next; } $p0 = substr("dANGO", $d, 1); $q0 = chr($c) ^ $p0; if( ord($q0) > 32 && ord($q0) < 127 && $q0 ne "'" ) { $d = ($d + 1) % 5; $p .= $p0; $q .= $q0; next; } # Select random character pair from dictionary die unless exists $dict{$c}; my $index = int(rand ($#{$dict{$c}} + 1)); my $pair = ${$dict{$c}}[$index]; $p .= substr($pair, 0, 1); $q .= substr($pair, 1, 1); } print "p =\n$p\nq =\n$q\n";