open(FIL,"prob59data.txt"); @letters = split(",",); close(FIL); $crypt = ""; foreach $l (@letters) { $crypt .= chr($l); } #i didnt quite solve this one, but i came close enough to find the answer. #i had additinoal characters marked that were "ok" to be in the result set. it resulted in a few dozen "hits", which i sorted through #this is a modified version of that program. print "Length of crypt: " . length($crypt) . " characters\n"; $n = length($crypt) / 3; print "Repeat $n times\n"; #the cipher is "god" $cipher = "god"; $cipher = ($cipher x int($n)) . 'g'; $restext = ""; for ($i = 0; $i < length($crypt); $i++) { $newchar = "" . chr(ord(substr($crypt,$i,1)) ^ ord(substr($cipher,$i,1))); $restext .= $newchar; $sum += ord($newchar); } open(FIL,">prob59solved.txt"); print FIL $restext; close(FIL); print "Sum: " . $sum; exit; for ($a = 0; $a < 26; $a++) { print "Searching " . chr(97 + $a) . "..\n"; for ($b = 0; $b < 26; $b++) { for ($c = 0; $c < 26; $c++) { $cipher = chr(97 + $a) . chr(97 + $b) . chr(97 + $c); $cipher = ($cipher x int($n)) . chr(97 + $a); #$cipher = "god" x int($n) . 'g'; #print "$cipher\n"; #exit; $restext = ""; $good = 1; for ($i = 20; $i < length($crypt) - 10; $i++) { $newchar = "" . chr(ord(substr($crypt,$i,1)) ^ ord(substr($cipher,$i,1))); $restext .= $newchar; if (! ($newchar =~ /[:alnum:]/ || $newchar =~ /[:space:]/ || $newchar =~ /[\!\.\,\?\'\"\;\:\[\]\+\-\=\)\(\&\$]/)) { #if (! $newchar =~ /[:graph:]/) { $good = 0; #print $newchar . "(" . ord($newchar) . ")"; #exit; } } #exit; #print $restext . "\n"; #exit; if ($good == 1) { print substr($cipher,0,3) . "\n"; print "Text: $restext\n\n"; exit; } } } }