Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

A slightly less simple obfuscation for a slightly less simple substitution cipher. My next stop in old forgotten encryption ciphers is the Vigenére cipher. This is a slightly more obfuscated encryption cipher than my last one - In case you haven't noticed, I'm increasing the obfuscation level as the encryption algorithm increases. This either takes a file as a parameter to encrypt in vigenere, or provided no input encrypts it's __DATA__.

Note: if you save this locally (and I don't know how you might run it otherwise) be sure to give it a filename of a good number of characters ( > 5) - The longer the filename, the better the encryption key.

#!/usr/bin/perl $ ..=$ _ for qw|$ @=/b..u\;/_@ =vqv \?qvcl+FOTO ,_@:_$;kbv($_@ =$ @;jd +/_;++\(d qR_"/2. ._;\(vz xH$ _@,xHjdy$ _@)) )$ @;$. =kbv[$ _@] ,_0= ~{}w {g|;$ +_=$ . ,y ,/FO\\{vzlu}\$dqR_Hjk\@yq(xybRc),(DA)/punz\\\@for\$him_to{stare},,s.. +$ _.gee; print map { map { $ %= 0 ;s '([A-Z])(?{$ %=1})'lc$ 1'e ;$ ;=$ .[ $ *] +[ - 97 + ord ]; $ *+= $ *== @ .-1? -$ *:1 ;ord> 96?$ %? uc$ ; :$ ; :$ _ }split/ +/}<DATA> __DATA__ The Vigenere cipher, known by some as 'le chiffre indechiffrable' (Fre +nch for 'the indecipherable cipher') is a method of encryption that uses a ser +ies of different Caesar ciphers based on the letters of a keyword, though the +re is some argument among cryptographic circles as to which incarnation of t +his particular polyalphabetic substitution can accurately be attributed to + Blaise de Vigenere. This implementation is a simple form of a polyalphabetic substitution. To encipher, a table of alphabets can be used, termed a + tabula recta, or Vigenere table. It consists of the alphabet written out 26 +times in different rows, each alphabet shifted cyclicly to the left compared + to the previous alphabet. Incidentally, there's a good chance that this plai +ntext is long enough to display the cryptographical weakness of this particu +lar algorithm. Can you spot it?

I'm currently working on the brute-force decryption for texts encrypted with this algorithm. It's working now, but I'd like to clean it up and make it more general, as well as optionally display HTML output.

I've found a somewhat reliable method for letter distribution frequency analysis that seems to work for a good number of test cases - Letter frequency analysis is the obvious weakness of this cipher. I'll post a followup with the cracking script a bit later...



--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[$%++]}

In reply to Vigenére cipher by chargrill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-19 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found