Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Breaking the indecipherable cipher, courtesy Charles Babbage.

by turo (Friar)
on May 19, 2006 at 19:26 UTC ( [id://550571]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Breaking the indecipherable cipher, courtesy Charles Babbage.
in thread Breaking the indecipherable cipher, courtesy Charles Babbage.

your algorithm works well your only fail is to feed your vigener cipher machine with simbols others than alphabetics ones.

Problems of keeping spaces on your ciphertext are that there are some words that are very common on your language (examples: the, and, of, I, you ...), and the same goes for other simbols like the ``''' and the ``?''. So in old cipher methods is important to remove this simbols (except on transposition ciphers like the scitale ^_^>)

i think your algorithm failed because of those spureous simbols

prove with this text instead:

TheVigenerecipherknownbysomeaslechiffreindechiffrableFrenchfor theindecipherablecipherisamethodofencryptionthatusesaseriesof differentCaesarciphersbasedonthelettersofakeywordthoughthereis someargumentamongcryptographiccirclesastowhichincarnationofthis particularpolyalphabeticsubstitutioncanaccuratelybeattributedtoBlaise deVigenereThisimplementationisasimpleformofapolyalphabetic substitutionToencipheratableofalphabetscanbeusedtermedatabula rectaorVigeneretableItconsistsofthealphabetwrittenout26times indifferentrowseachalphabetshiftedcycliclytotheleftcomparedtothe previousalphabetIncidentallytheresagoodchancethatthisplaintext islongenoughtodisplaythecryptographicalweaknessofthisparticular algorithmCanyouspotit

perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

Replies are listed 'Best First'.
Re^4: Breaking the indecipherable cipher, courtesy Charles Babbage.
by chargrill (Parson) on May 19, 2006 at 20:29 UTC

    Yeah - perfect example: The following text, taken from Simon Singh's Code Challenge:

    ... fails miserably, but if I save it as "trajan" and run the following:

    $ cat trajan | perl -pe 's/\W|\s//gm' | perl babbage.pl

    It works like a champ. But this treatment can also foil my "best guess" as to the key length:

    $ tail -12 vigenere.pl | perl -pe 's/\W|\s//gm' \ | perl vigenere.pl - | perl babbage.pl

    ... the "key" found is "vrgpn", and the plaintext is then shown as "tyekipelepetiehnrinmwebnsxmcaqlvcwio..."

    All of which makes me think I need to do some refactoring to look out for these kinds of problems, or at the very least add some interactivity along the lines of the posted solution to the code challenge mentioned above.



    --chargrill
    $,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}

      automation is right ;) ...

      i did the same as you did, but i've obtained the correct result ...

      turo@somewhere:~# tail -12 vigenere.pl | perl -pe 's/\W|\s//gm' | pe +rl vigenere.pl - | perl babbage.pl Key: vigenerepl Plaintext: thevigenerecipherknownbysomeaslechiffreindechiffrable ...

      The more bizarre thing, is that if i rename the file to chargrill and do the same, the result is wrong

      turo@somewhere:~# tail -12 chargrill | perl -pe 's/\W|\s//gm' | perl + chargrill - | perl babbage.pl Key: a Plaintext: voemoxmyptlczvymcvpvwehpazxghscktptqhyeztumnskmfigstpqtl ...

      Maybe the solution is to choose a keylengh (and key), get the result for the bests fits, and pass some test to see if the result is right or not (based on letter frequencies) ... or something like that

      turo

      PS: only one more question, which book did you bought? (I've got the David Khan's Codebreakers; but is too big) ... Is the Sinmon Singh's one? ... woff, woff

      perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://550571]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-25 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found