Hacking Secret Ciphers with Python

(Ann) #1

252 http://inventwithpython.com/hacking


Email questions to the author: [email protected]


Getting a List of Candidates for a Cipherword


To take a guess at what HGHHU could decrypt to, we can go through the dictionary file and find
all of the words that also have a word pattern of 0.1.0.0.2. In this book, we will call these
plaintext words (that have the same word pattern as the cipherword) the candidates for that
cipherword:


Ciphertext word: H G H H U
Word pattern: 0.1.0.0.2

Candidates: (^) p u p p y
(^) m o m m y
(^) b o b b y
l u l l s
n a n n y
l i l l y
So if we look at the letters in the cipherword (which will be called cipherletters in this book),
we can guess which letters they may decrypt to (we will call these letters the cipherletter’s
potential decryption letters in this book):
Cipherletters: (^) H G U
Potential decryption letters: p u y
m o y
b o y
l u s
n a y
(^) l i y
From this table we can create a cipherletter mapping:
 The cipher letter H has the potential decryption letters P, M, B, L, and N
 The cipher letter G has the potential decryption letters U, O, A, and I
 The cipher letter U has the potential decryption letters Y and S
 All of the other cipher letters besides H, G, and U will have no potential decryption letters.
When we represent a cipherletter mapping in Python code, we will use a dictionary value:

Free download pdf