Perl: the Markov chain saw PerlMonks

### Re: Crypto Japh

 on Dec 06, 2005 at 17:03 UTC ( #514553=note: print w/replies, xml ) Need Help??

veRy Nic3 !
Here is my solution to this riddle ;)

The core of the job is done by the first map which will crypt the 6 words of the string "writing Library. Building consider TO(\$FOO) *binary*" (split on space) with the numbers at the begining of the list @:: ( obtained with shift ) .

This step can be rewrited as :

```@keys=qw'79 11 34 69 41 27';
@list_to_crypt = split/ /, 'writing Library. Building consider TO(\$FOO
+) *binary*' ;
@result=map{ crypt (\$_.' ', shift @keys)  } @list_to_crypt ;
If you print @result you will see :
```79jUStLZ6Ck9c
11anOTHZ33A12
34ERehEMmayDo
69pERLsGUZYU2
41HAcKS9/lrEQ
27eRTYtC6a5HI
Now, in the same map liverpole pops the value at the end of @:: into \$x , which is used into a regexp against the crypted values . This can be rewriten as :
```@matcher =  qw'2 4 4 2 5 4' ;
foreach \$crypted (@result ) {
\$x = pop @matcher ;
\$crypted  =~/..(.{\$x}).*/g ;
push @final, \$1 ;
}
If you print @final you get :
```jUSt
anOTH
ER
pERL
HAcK
eR
The match is fairly understandable : it could read as "any character", "any character", "remember those next \$x any character", "anything till the end of line" . And as it happens, \$x selects the characters we need from @result !

And the next map is giving the proper formating .

But there is one last thing that i didn't know here : in the first map, the value returned by the map function is what was matched in the regexp ! Now that's interesting !!

Replies are listed 'Best First'.
Re^2: Crypto Japh
by liverpole (Monsignor) on Dec 06, 2005 at 18:14 UTC
Very nice analysis++.

The thing that took the most time was, of course, finding words (and combinations of word fragments) which gave the appropriate crypt results, since crypt is a one-way algorithm.  I was especially surprised when I found the fairly long (5-letter) string "anOTH".

@ARGV=split//,"/:L"; map{print substr crypt(\$_,ord pop),2,3}qw"PerlyouC READPIPE provides"

Create A New User
Node Status?
node history
Node Type: note [id://514553]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
As of 2017-08-17 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (286 votes). Check out past polls.

Notices?