Hacking Secret Ciphers with Python

(Ann) #1
Chapter 17 – The Simple Substitution Cipher 249

Using key /{9@6hUf:q?_)^eTi|W1,NLD7xk(-SF>Iz0E=d;Bu#c]w~'VvHKmpJ+}s8y&
XtP43.b[OA!\Q<M%$ZgG52YloaRCn"`rj
The encrypted message is:
#A/3/%3$/\2/ZAAO5O[/3/A3bY/a
\b/!ZO2/3!3\$2Y/\2/\$2Y\$bY2)/O/a\MM/2b5lY\$\nO
/\Y/bMZ2OMC)/3$[/l$MO22/Y
O/Oo[O$bO/\2/ZoO5aOM%\$!)/O/a\MM/5OAl2O/YZ/.OM\OoO
/\Ye/#A)/Z$/YO/ZYO5/3$[)/O/\2/ZAAO5O[/2Z%OY\$!/a\b/3AAZ5[2/3/5O32Z$/AZ5/
3bY\$!/\$/3bbZ5[3$bO/YZ/
\2/\$2Y\$bY2)/O/a\MM/3bbOgY/\Y/OoO$/Z$/YO/2M!YO2Y/
Oo[O$bOe/p
O/Z5!\$/ZA/%CY2/\2/ORgM3\$O[/\$/Y\2/a3Ce/^0O5Y53$[/Kl22OMM


This message has been copied to the clipboard.


Practice Exercises, Chapter 17, Set C


Practice exercises can be found at http://invpy.com/hackingpractice17C.


Summary


In this chapter, we have learned about the new “set” data type. In many of our programs, lists are
much easier to use than sets, but sets are a simple way to get rid of duplicate values from lists or
strings.


The isupper() and islower() string methods can tell us if a string value is made up of only
uppercase or lowercase letters. And the sort() list method is very useful at putting the items in
a list in order.


The simple substitution cipher has far too many possible keys to brute-force through. This makes
it impervious to the techniques that our previous cipher hacking programs have used. We are
going to have to make smarter programs in order to break this code.


In the next chapter, we will learn how to hack the simple substitution cipher. Instead of brute-
forcing through all the keys, we will use a much more intelligent and sophisticated algorithm.

Free download pdf