Perl Home Notes Exercises Resources perl Thoughts Jen's Home Summer Perl Seminar

Week 4 Exercises

Exercise 1 (hard)

In reality, the ADFGX cipher we discussed in class is a little more complex. Instead of printing out each two letter combination that substitutes for a single letter, there is an additional step. The messages we produced are written out in rows under a word called a transposition key. That key is then rearranged in alphabetical order to change the order of the columns. Then, the letters are read off in columns and transmitted. Wikipedia has a nice example of how this works.

Write a script that will encrypt and decrypt a message using this more general method. As an example, use the word "HEART" as your transposition key.

Extension 1: Modify your script to encrypt any document read from a file.

Extension 2: Modify your script to encrypt any document read from the web.