Professional Documents
Culture Documents
Historical Ciphers
Simplest way to decipher a Cesar cipher-based cipher text is based on cipher texts histogram (i.e., letters
frequency) analysis. By doing this, one can observe that the most frequent symbol within the cipher text
is the letter Q. With the highest probability, Q replaces A (i.e., the most frequent symbol in Romanian
plain-texts1). Now the displacement between A and Q is 16.
Symbol Q B U D E, H, I, S, Y C, F, J, P, W
Frequency 25.00% 13.88% 11.11% 8.33% 5.55% 2.77%
2. Decipher the following message knowing that the plain-text was written in English:
VKRIMHLRLMXF'L LXVNKBMR TGW KHUNLMXGLL PTL TLLXLLXW PBMA MAX TBW
HY OTKBHNL FXMAHWL LNVA TL DXR LITVX TGW DXR'L LXGLBMBOBMR MH LFTEE
VATGZXL TGTERLXL, WBYYXKXGMBTE TGW LMTMBLMBVTE TGTERLXL XMV. TGW
MAX VHKKXLIHGWBGZ XQIXKBFXGMTE KXLNEML LAHPXW MATM MAX IKHIHLXW
BFTZX VKRIMHLRLMXF ATL T WXLBKTUEX EXOXE HY LXVNKBMR.
Under the same methodology, screening cipher texts histogram, one can observe that the most frequent
symbol within the cipher text is the letter L. Thus, as E is the most frequent symbol in English plain-texts
one can jump to the conclusion that the deciphering key is 7 (i.e., value of the displacement between the
two symbols). But, with the deciphering of the cipher text, it will be proved that this conclusion is false,
as the result will be still illegible:
Symbol L X T M B G, H, K W E, R
Frequency 14.28% 12.40% 9.39% 9.02% 6.01% 4.88% 4.51% 4.13%
However, with a more careful analysis of cipher texts histogram, someone else observes that there are
two symbols with quite close frequencies. Thus, it might say that the correct key lies somewhere between
these two symbols, i.e., { , }. Thus, at the second iteration, it will be proved once again that
the achieved conclusion in false, as the result will be still illegible:
1 see APPENDIX E
Guessing can continue; however, the problem is much simpler than it looks. Looking at the cipher text one
can find the singular T symbol (i.e., 5th row). So, we should wonder: (i) which are the symbols more likely
to appear alone (e.g., a, as in a car or I, as in I am) in an English plain-text (i.e., as long as possible);
(ii) between these symbols which has the highest probability (i.e., to appear alone in a plain-text, as long
as possible). Answering these two questions, one can correctly conclude that, with the highest probability,
T replaces A. Now the displacement between A and T is 19 and the deciphered text is:
OBS: To counteract the final case (i.e., where the link between the plain-text and the cipher text is
betrayed by a single symbol), usually, the cipher text: (i) is divided into equal size blocks (with the final
one padded, if it hasnt the proper size); (ii) is given as a single, continuous, block.
3. Decipher the following message knowing that the plain-text was written in English:
JAJSN SHWDU YTQTL DXNQJ SHJNX LTQIJ SCCCC
P A S W O
R D B C E
F G H I,J K
L M N Q T
U V X Y Z
R: ALLAN TURING
2. Decipher the following message knowing that the chosen password was POVESTE:
BM CI AS AB
P O V E S
T A B C D
F G H I.J K
L M N Q R
U W X Y Z
R: ANECDOTA
(i) 26 = ( 9 3) 26 = 6
(ii) 26 = (17 0) 26 = 17
(iii) 26 = (18 18) 26 = 0
(iv) 26 = (22 7) 26 = 15
(v) 26 = (18 11) 26 = 7
(vi)
2. Find the password with which the following cipher text was obtained:
KVGLGVPBNLEIUZDTEEKIWHWSGKDTIRHIKVYIKBTKIJVQCHXZQVUVVDCVNWIFRTTYMMCTXU
KRPLQLMEIQCJSDRMIPXZQVLPXYEWJUXIKMHZYTJIHIYCIIGPEXTMTJIZVIAFSIUXPPRSNIRRWVC
ZTZSIVAHBGYCABHQRKIDSMDRVTWXLPAPAYIPDTUYJCVSTEEIIAPERTMPTSEIBWLQRKVIVYIK
AIPGRVBGHGKKWCZSWVPTZYDOMGZIRUWCPRNKVILVKJMHRMIGADYXJHZDTXYGXGHLFXIKH
PCGGPUHGQQPUESTIHVZRTMIOIWCDDBVZVMSLWKKVPAMFPADMXFWZXZXJFCTASKJMXYQVF
QTCECCBBVWGJMGLSIVWIOIEGIGICTCAISIJOICFXICVHFPMCVXHRKQECZWLEPPZWZDQJIVRUW
KZMXJQHVEICKABNECXDJEFTBPYKLOCGLWYCDTIITQUTPQGQZIHRKRTPJIJQNXUXVTMHAJFTB
DBVZUBHYITGVISCIWZPSXFWZXZQYCAPSWFFMKLPFRMSHRUKBUVGLUMHVRGTWBVXZPOUV
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A
BDPXJOWCHWKGZXLWKJMUPZVOWCHWKGZXLWNKBWLBKGZXVVGCQCAMEIEWPGYYMGLEUF
MSASKJMLVVCFBDBVZUBXJLVTQIHKVRZTZIIXMIOIZTKWHVREBTYMJVQRZEWVMGTSIGBW
HRWQCGOYEFZTKEEFNXMXPAMPYW
Assuming that we have enough cipher text, breaking Vigenre assumes:
(i) Find the length of the key:
For = 1, , where represents the largest likely key length, perform a -positions right
cyclic shift of the cipher text and count the number of positions in which they are the same.
k 1 2 3 4 5 6 7 8 9 10
matches 13 8 8 13 11 19 10 7 10 6
Screening the table above (i.e., computed for = 1,10), as most matches are found for a
shift of six positions, we can assume that the length of the key KL = 6.
OBS: This method proves to be inefficient in case of small size cipher texts in which case is quite difficult
to match cipher texts histogram with typical English texts histogram. [Example given in Appendix A].
- In our example:
The signature for groups of the sampled cipher text symbols, resp., for a usual English
written plain-text are plotted.
Analyzing the signature of the first group of sampled cipher text symbols, one can notice a
unique high frequency peak on the 3rd position (i.e., the 0.132 value marked with red) and
jump to the false conclusion that it matches letter E (i.e., as it is the most frequent symbol
in English plain-texts). In fact, screening more carefully groups signature, the frequencies
pattern which starts with the 3rd position and finishes with the 11th one matches better (i.e.,
with a two-position left circular shift) the signature of a usual English written plain-text for
the same interval, as for the entire signature. Thus, first keywords letter is C.
Applying the same reasoning, one can continue and find each and every letter of the key (i.e.,
as shown in the following).
2 With the correspondences A = 0, B = 1, C = 2 Z = 25, for a particular keyword letter, all cipher texts letters encrypted
with will be shifted to the right the corresponding number of positions. For the group containing these cipher text letters, if
the signature of the group is shifted to the left the same number of positions, wrapping from the left edge of the graph to
the right when necessary, the signature should be as closely aligned as possible with the one of ordinary English written plain-
text. Thus, shifting the signature of a group, looking for where it aligns as closely as possible with the one of ordinary English,
can help identify the keyword letter that produced the shift. Doing this for each group should allow the entire keyword to be
determined one letter at a time.
A
0.000 0.007 0.081 0.034 0.054 0.010
B
0.003 0.010 0.041 0.037 0.108 0.000
0.034 0.010 0.014 0.078 0.030 0.132 C
D
- In our example:
The characters probabilities vectors for a usual English written plain-text and of the first
group (i.e., for = 1) are:
= [0.0821, 0.0150, 0.0230, 0.0479, 0.1237, 0.0225, 0.0208, 0.0645, 0.0676, 0.0018,
0.0087, 0.0393, 0.0254, 0.0705, 0.0767, 0.0163, 0.0009, 0.0550, 0.0617, 0.0921,
0.0291, 0.0087, 0.0254, 0.0013, 0.0195, 0.0006].
= [0.0101, 0.0000, 0.1318, 0.0101, 0.0304, 0.0405, 0.0811, 0.0236, 0.0270, 0.0541,
0.0811, 0.0000, 0.0000, 0.0304, 0.0236, 0.0439, 0.0912, 0.0270, 0.0034, 0.0676,
0.0676, 0.1047, 0.0270, 0.0169, 0.0068, 0.0000].
= [0.0313, 0.0382, 0.0649, 0.0402, 0.0320, 0.0319, 0.0431, 0.0317, 0.0362, 0.0427,
0.0361, 0.0321, 0.0372, 0.0419, 0.0413, 0.0430, 0.0421, 0.0475, 0.0349, 0.0310,
0.0335, 0.0389, 0.0334, 0.0355, 0.0446, 0.0351].
For the first group the maximum dot product between the two vectors is found at 3rd
position and thus the first keywords letter is C.
If the procedure is repeated, the keyword letter associated to each group is found.
R: CIPHER
Being given an 6 6 Richelieu encryption grid and knowing that for 3 90 clockwise rotation cycles all
grids cells should be covered by the chosen pattern (i.e., composed of 9 hatched/punched/transparent
cells) these are the steps that must be followed:
(i) Starting with the outer cells square, a maximum of five hatches must be chosen so that, during the
3 90 clockwise rotation cycles, all cells (i.e., of the outer square) to be covered while avoiding
overlapping them. This steps is showcased graphically in Fig. no. 1.
3
Subsequent MATLAB R2014b is presented in APPENDIX B
a) b) c) d) e)
Fig. no. 1 outer cells square: a), chosen hatches (i.e., gray color) and their image during the rotation cycles (i.e., red
color): b) d), outcome of the first step: e)
(ii) Starting with the 2nd outer cells square, a maximum of three hatches must be chosen so that, during
the 3 90 clockwise rotation cycles, the cells of the 2nd outer square to be covered while avoiding
overlapping them. This steps is showcased graphically in Fig. no. 2.
a) b) c)
Fig. no. 2 2nd outer square: a), chosen hatches (i.e., gray color) and their image during the rotation cycles (i.e., red
color): b), outcome of the second step (i.e., including the first one): c)
(iii) Starting with inner cells square, only one hatch remains to be chosen so that, during the clockwise
rotation cycles, the cells of the inner square to be covered while avoiding overlapping them. This steps
is showcased graphically in Fig. no. 3.
a) b) c)
Fig. no. 3 inner square: a), chosen hatch (i.e., gray color) and its image during the rotation cycles (i.e., red color): b),
outcome of the third step (i.e., including the first two): c)
Encryption process itself involves overlapping the encryption grid (i.e., Fig. no. 3.c)) over the plain-text
grid and reading / writing letter that are overlapped by hatches. Reading / writing is going through rows,
from up to down and from left to right. For each read of a blank space, a marker in inserted (e.g., an
underscore or backslash) in order to simplify the reading (i.e., during the decryption process) of multiple
consecutive blank spaces. This procedure applies for all 3 90 clockwise rotation cycles (i.e., starting
with a 0 rotation), as shown below.
R: ARA_FSMEIGHZIONR_NE__PET_AL_TUAOATON
13 22 10
= 9 3 16 , det( ) = 7.
23 13 5
(ii) Format the message (i.e., removing spaces within, padding if necessary and converting message chars
to equivalent integer number)
The length of the message does not factor by 3 and thus it is padded, twice, with the last char
within. Messages associate matrix, i.e., hereafter denoted M, is computed as follows:
= [87 69 76 79 86 69 77 65 84 72].
= [23 5 12 15 22 5 13 1 20 8 8 8].
23 15 13 8
= 5 22 1 8.
12 5 20 8
(iii) Multiply, i.e., modulo 26, the encryption matrix with messages associated matrix
The resulted cipher texts associated matrix, i.e., hereafter denoted EM is:
9 1 1 22
= 24 21 24 16 .
4 6 22 26
R: IXDAUFAXVVPP
2 3 15
2. Decipher the following message knowing that the encryption key was = 5 8 12 :
1 13 4
SQYEDXEIKOBLPYHUAX
124 183 84 10 19 16
= 19 8 7 51 ( 26) = 4 23 7 .
57 23 1 17 5 19
= [83 81 89 69 68 88 69 73 75 79 66 76 80 89 72 85 65 88].
19 5 5 15 16 21
= 17 4 9 2 25 1 .
25 24 11 12 8 24
(iii) Multiply, i.e., modulo 26, the decryption matrix with cipher texts associated matrix
The resulted plain texts associated matrix, i.e., hereafter denoted DC is:
3 16 7 16 9 15
= 18 20 18 8 19 15 .
25 15 1 25 3 12
(iv) Format the plain text (i.e., convert associated matrixs elements from integer numbers to equivalent
alphabet letters):
The resulted cipher text is:
R: CRYPTOGRAPHYISCOOL
At its simplest, columnar transposition enters the plaintext (i.e., is written horizontally) into a rectangle of
a predetermined width (i.e., equal with keys length; e.g., = 3, in our case) and extracts ciphertext by
columns, in the order determined by the numerical key.
2 1 3
E L E
C T R
I C H
O T P
L A T
E X X
The numerical key associated with the keyword ORANGE is = (5, 6, 1, 4, 3, 2).
5 6 1 4 3 2
R E Q U E S
T R E I N F
O R C E M E
N T S I M M
E D I A T E
L Y X X X X
1. Find the password with which the following cipher text was obtained:
EZNWXFUGHAIDUATJYIKBNHRUTWQBWKPMHZARUIHZIJUMSDMKJBWLEZFWUCEI
KWJZQVVPDKWJWKWHWBGGHWETGICKOVAAHLRJKBXCMKABDZQRNTROEEIMHH
RRNGHLWUKNULVVPBXHPRPLHAEKKAIPGRNICHPPUMHLXTCVSALVEWGYIJRWCK
MEIMMWIIKUTUXRNZTZYCVAHOSNGLIOEKVPTWVFRWHLHZOIVLGIAXIVWPUBTTL
RUISLWZTIQSICGDTSSWUMRBVZVG
For = 1, , where represents the largest likely key length, perform a -positions right
cyclic shift of the cipher text and count the number of positions in which they are the same.
k 1 2 3 4 5 6 7 8 9 10
matches 13 8 8 13 11 19 10 7 10 6
Screening the table above (i.e., computed for = 1,10), as most matches are found for a
shift of six positions, we can assume that the length of the key KL = 6.
Being difficult to match cipher texts histogram with typical English texts histogram the
graphical method proves to be inefficient.
- Mathematical method:
The characters probabilities vectors for a usual English written plain-text and of the first
group (i.e., for = 1) are:
= [0.0821, 0.0150, 0.0230, 0.0479, 0.1237, 0.0225, 0.0208, 0.0645, 0.0676, 0.0018,
0.0087, 0.0393, 0.0254, 0.0705, 0.0767, 0.0163, 0.0009, 0.0550, 0.0617, 0.0921,
0.0291, 0.0087, 0.0254, 0.0013, 0.0195, 0.0006].
= [0.0667, 0.0000, 0.0222, 0.0000, 0.0444, 0.0222, 0.0889, 0.0000, 0.0444, 0.0222,
0.1333, 0.0000, 0.0000, 0.0889, 0.0222, 0.0667, 0.0000, 0.0444, 0.0000, 0.0444,
0.1778, 0.0889, 0.0222, 0.0000, 0.0000, 0.0000].
= [0.0401, 0.0427, 0.0593, 0.0397, 0.0302, 0.0270, 0.0566, 0.0435, 0.0358, 0.0377,
0.0341, 0.0256, 0.0375, 0.0413, 0.0320, 0.0367, 0.0415, 0.0516, 0.0369, 0.0358,
0.0362, 0.0329, 0.0436, 0.0297, 0.0320, 0.0299].
For the first group the maximum dot product between the two vectors is found at 3rd
position and thus the first keywords letter is C. If the procedure is repeated, the keyword
letter associated to each group is found.
R: CIPHER
A
0.000 0.023 0.068 0.000 0.089 0.067
B
0.023 0.000 0.046 0.000 0.133 0.000
0.046 0.000 0.046 0.068 0.000 0.022 C
D
clear; clc;
%Open and read the cipher text; Change file path if necessary
Cipher_Text = textread('H:\Educational Activities\Applied Computer Sciences\
Criptograpy and Information Security\Vigenere\Short_Ciphertext.txt', '%c', 266);
Cipher_Text = Cipher_Text';
Cipher_Text = double(Cipher_Text);
%Compute frequencies for the symbols within groups of resampled cipher text
Cipher_Text_Groups_Frequencies = zeros(Key_Length, 26);
for i = 1 : Key_Length
for j = 1 : Key_Length : length(Cipher_Text)
Cipher_Text_Groups_Frequencies (i, Cipher_Text(j)-64) =
Cipher_Text_Groups_Frequencies (i, Cipher_Text(j)-64) + 1;
end
Cipher_Text_Groups_Frequencies (i,:) =
Cipher_Text_Groups_Frequencies(i,:)/sum(Cipher_Text_Groups_Frequencies(i,:));
for i = 1 : Key_Length
for j = 1 : 26
Closeness_Matrix(i,j) =
dot(Cipher_Text_Groups_Frequencies(i,:), English_Text_Frequencies);
for i = 1 : Key_Length
KEY =
strcat(KEY,char(find(Closeness_Matrix(i,:)==max(Closeness_Matrix(i,:)))+64));
end
KEY
APPENDIX C
clear; clc;
Plain_Text = Plain_Text';
Plain_Text = double(Plain_Text);
Cipher_Text
else
end
APPENDIX D
clear; clc;
clear; clc;
%%Open and read the plain-text
Cipher_Text = textread('H:\Educational Activities\Applied Computer Sciences\
Criptograpy and Information Security\Hill\Cipher_Text.txt', '%c', 266);
Cipher_Text = Cipher_Text';
Cipher_Text = double(Cipher_Text);
%%Knowing the ciphering matrix (i.e., the encryption key) compute its inverse
%%Compute det(Ciphering_Matrix)
CM_Determinant = uint8(mod(det(Ciphering_Matrix),26));
Deciphered_Text
APPENDIX E
Let and , two positive integers such that ( , ) = . Then has a unique multiplicative inverse
modulo and it can be computed using the Euclidean Algorithm (i.e., as in the following example):
7 mod 26
26 = 7(3) + 5 5 = 26 7(3)
7 = 5(1) + 2 2 = 7 5(1)
5 = 2(2) + 1 1 = 5 2(2)
2 = (2)
1 = 5 2(2) = 5 7 5(1) (2) = 5 7(2) + 5(2) = 5(3) 7(2),
1 = 26 7(3) (3) 7(2) = 26(3) 7(9) 7(2) = 26(3) 7(11) = 26(3) + 7(11),
1 7(11) mod 26 mod 26.
11 mod 26
26 = 11(2) + 4 4 = 26 11(2)
11 = 4(2) + 3 3 = 11 4(2)
4 = 3(1) + 1 1 = 4 3(1)
1 = (1)
1 = 4 3(1) = 4 11 4(2) (1) = 4 11(1) + 4(2) = 4(3) 11(1),
1 = 26 11(2) (3) 11(1) = 26(3) 11(6) 11(1) = 26(3) 11(7) = 26(3) + 11(7),