Chapter 13 – Hacking the Transposition Cipher 195
- main()
Lines 48 and 49 call the main() function if this program was run by itself, rather than imported
by another program that wants to use its hackTransposition() function.
Practice Exercises, Chapter 13, Set A
Practice exercises can be found at http://invpy.com/hackingpractice 13 A.
Summary
This chapter was short like the “Breaking the Caesar Cipher with the Brute-Force Technique”
chapter because (also like that chapter) most of the code was already written in other programs.
Our hacking program can import functions from these other programs by importing them as
modules.
The strip() string method is useful for removing whitespace (or other) characters from the
beginning or end of a string. If we use triple quotes, then a string value can span across multiple
lines in our source code.
The detectEnglish.py program removes a lot of the work of inspecting the decrypted output to see
if it’s English. This allows the brute-force technique to be applied to a cipher that can have
thousands of keys.
Our programs are becoming more sophisticated. Before we learn the next cipher, we should learn
how to use Python’s debugger tool to help us find bugs in our programs.