Hacking Secret Ciphers with Python

(Ann) #1

122 http://inventwithpython.com/hacking


Email questions to the author: [email protected]


Summary


Whew! There were a lot of new programming concepts introduced in this chapter. The
transposition cipher program is much more complicated (but much more secure) than the Caesar
cipher program in the last chapter. The new concepts, functions, data types, and operators we’ve
learned in this chapter let us manipulate data in much more sophisticated ways. Just remember
that much of understanding a line of code is just evaluating it step by step the way Python will.


We can organize our code into groups called functions, which we create with def statements.
Argument values can be passed to functions for the function’s parameters. Parameters are local
variables. Variables outside of all functions are global variables. Local variables are different
from global variables, even if they have the same name as the global variable.


List values can store multiple other values, including other list values. Many of the things you can
do with strings (such as indexing, slicing, and the len() function) can be used on lists. And
augmented assignment operators provide a nice shortcut to regular assignment operators. The
join() method can join a list that contains multiple strings to return a single string.


Feel free to go over this chapter again if you are not comfortable with these programming
concepts. In the next chapter, we will cover decrypting with the transposition cipher.

Free download pdf