Substitute Cipher
Substitute Cipher
How to Encrypt:
For every letter in the message M :
1. Convert the letter into the number that matches its order in the
alphabet starting from 0, and call this number X.
( A=0, B=1, C=2, ...,Y=24, Z=25)
2. Calculate: Y = (X + K) mod 26
3. Convert the number Y into a letter that matches its order in the
alphabet starting from 0.
For Example: We agree with our friend to use the Shift Cipher
with key K=19 for our message.
We encrypt the message "KHAN", as follows:
So, after applying the Shift Cipher with key K=19 our message text
"KHAN" gave us cipher text "DATG".
How to decrypt:
For every letter in the cipher text C :
1. Convert the letter into the number that matches its order in the
alphabet starting from 0, and call this number Y.
(A=0, B=1, C=2, ..., Y=24, Z=25)
2. Calculate: X= (Y - K) mod 26
3. Convert the number X into a letter that matches its order in the
alphabet starting from 0.
(A=0, B=1, C=2, ..., Y=24, Z=25)
Our friend now decodes the message using our agreed upon key
K=19. As follows:
So, after decrypting the Shift Cipher with key K=19 our friend
deciphers the cipher text "DATG" into the message text "KHAN".
To do that; choose a word, remove the surplus letters from the word
and write the rest of the alphabet next to it.
(Do not write the letters which are on your word as well.)
*You can do the same thing using words instead of letters. For
example in the sentence "Hello World" you can use "-1,2" and you
will do the same thing but in the word "Hello" you will use "-1" and in
" World" you will use "2".
In cryptography, we call the message that we want to keep secret the plaintext. Let’s
say we have a plaintext message that looks like this:
Converting the plaintext into the encoded message is called encrypting the plaintext.
The plaintext is encrypted into the ciphertext. The ciphertext looks like random letters, so
we can’t understand what the original plaintext was just by looking at the ciphertext. Here
is the previous example encrypted into ciphertext:
WTGT XH PCDIWTG BTHHPVT IWPI NDJ HWDJAS WPKT CD IGDJQAT QGTPZXCV LXIW ATIITG
UGTFJTCRN PCPANHXH
1) Rail-Fence Technique
This technique is a type of Transposition technique and does is write the plain
text as a sequence of diagonals and changing the order according to each
row.
Example,
The rail fence cipher is also called a "zigzag cipher" because we make a
rectangle box and write plain text into it in a zigzag form. It is a form of
transposition cipher that jumbles up the order of the letters of a message
using a basic algorithm. It derives its name from how it is encrypted.
The rail fence cipher works by writing your plain text or message on alternate
lines across the prail and then reading off each line or rows in turn by turn.
Example
The plaintext we have i.e "defend the east wall" having a key size or the size
of the row is 3, we get the encryption method below,
That at the end of the message we have inserted two "X"s. These are called
nulls and act as placeholders. We do this to make the text fit into the rail so
that there is the same number of letters on the top row as well as on the
bottom row. Otherwise, it is not necessary, it makes the decryption process a
bit easier if the text has this format.
• Hence, the Rail Fence matrix can be constructed likely. Once we have
got the matrix we can find-out the places where plain texts should be
placed using the same way as we doe in the encryption method of
moving diagonally up and down alternatively to form text.
• Then, we fill the cipher-text accordingly to row-wise. After filling the
text, we traverse the matrix in the zig-zag form to get the original text or
the plain text.
Example
If we get the ciphertext "TEKOOHRACIRMNREATANFTETYTGHH", it will be
encrypted with a key size of 4.
We start by placing the "T" in the first square. You then dash the diagonal
down places until you get back to the top line, and place the "E" here.
Continuing to fill the rows you get the pattern below,
As we have a key size of 4 and the length of the message is 28 so we make like
this and continues this till all the text does not fit into it.
transposition cipher, simple data encryption scheme in which plaintext characters are
shifted in some regular pattern to form ciphertext.
In manual systems transpositions are generally carried out with the aid of an easily
remembered mnemonic. For example, a popular schoolboy cipher is the “rail fence,” in
which letters of the plaintext are written alternating between rows and the rows are then
read sequentially to give the cipher. In a depth-two rail fence (two rows) the message WE
ARE DISCOVERED SAVE YOURSELF would be
written
Simple frequency counts on the ciphertext would reveal to the cryptanalyst that letters
occur with precisely the same frequency in the cipher as in an average plaintext and,
hence, that a simple rearrangement of the letters is probable.
The rail fence is the simplest example of a class of transposition ciphers, known as route
ciphers, that enjoyed considerable popularity in the early history of cryptology. In general,
the elements of the plaintext (usually single letters) are written in a prearranged order
(route) into a geometric array (matrix)—typically a rectangle—agreed upon in advance by
the transmitter and receiver and then read off by following another prescribed route
through the matrix to produce the cipher. The key in a route cipher consists of keeping
secret the geometric array, the starting point, and the routes. Clearly both the matrix and
the routes can be much more complex than in this example; but even so, they provide little
security. One form of transposition (permutation) that was widely used depends on an
easily remembered key word for identifying the route in which the columns of a
rectangular matrix are to be read. For example, using the key word AUTHOR and ordering
the columns by the lexicographic order of the letters in the key
word
In decrypting a route cipher, the receiver enters the ciphertext symbols into the agreed-
upon matrix according to the encryption route and then reads the plaintext according to
the original order of entry. A significant improvement in cryptosecurity can be achieved
by reencrypting the cipher obtained from one transposition with another transposition.
Because the result (product) of two transpositions is also a transposition, the effect of
multiple transpositions is to define a complex route in the matrix, which in itself would be
difficult to describe by any simple mnemonic.
In the same class also fall systems that make use of perforated cardboard matrices called
grilles; descriptions of such systems can be found in most older books on cryptography.
In contemporary cryptography, transpositions serve principally as one of several
encryption steps in forming a compound or product cipher.
nother approach to cryptography is transposition cipher.
Transposition Ciphers
One modern transposition cipher is done by writing the message in rows, then forming
the encrypted message from the text in the columns.
Example 6
Encrypt the message “Meet at First and Pine at midnight” using rows 8 characters
long.
Solution
We write the message in rows of 8 characters each. Nonsense characters are added to
the end to complete the last row.
MEETATFIMEETATFI
RSTANDPIRSTANDPI
NEATMIDNNEATMIDN
IGHTPXNRIGHTPXNR
We could then encode the message by recording down the columns. The first column,
reading down, would be MRNI. All together, the encoded message would be MRNI
ESEG ETAH TATT ANMP TDIX FPDN IINR. The spaces would be removed or
repositioned to hide the size of table used, since that is the encryption key in this
message.
Example 7
Decrypt the message CEE IAI MNL NOG LTR VMH NW using the method above with
a table with rows of 5 characters.
Solution
Since there are total of 20 characters and each row should have 5 characters, then there
will be 20/5=4 20/5=4 rows.
We start writing, putting the first 4 letters, CEEI, down the first column.
CALLMCALLM
EINTHEINTH
EMORNEMORN
INGVWINGVW
We can now read the message: CALL ME IN THE MORNING VW. The VW is likely
nonsense characters used to fill out the message.
To make the encryption key easier to remember, a word could be used. For example,
if the key word was “MONEY”, it would specify that rows should have 5 characters
each. The order of the letters in the alphabet would dictate which order to read the
columns in. Since E, the 4th letter in the word, is the earliest letter in the alphabet from
the word MONEY, the 4th column would be used first, followed by the 1 st column (M),
the 3rd column (N), the 2nd column (O), and the 5th column (Y).
Example 8
Encrypt the message BUY SOME MILK AND EGGS using a transposition cipher with
key word MONEY.
Solution
M O N E Y
2 3 4 1 5
B U Y S O
M E M I L
K A N D E
G G S P K
As before, we’d then remove or reposition the spaces to conceal evidence of the
encryption key.
Try it Now 3
Encrypt the message “Fortify the embassy” using a transposition cipher with key word
HELP
Answer
Example 9
Decrypt the message RHA VTN USR EDE AIE RIK ATS OQR using a row-and-column
transposition cipher with keyword PRIZED.
Solution
The keyword PRIZED tells us to use rows with 6 characters. Since D comes first in the
alphabet, we start with 6th column. Since E is next in the alphabet, we’d follow with the
5th column. Continuing, the word PRIZED tells us the message was recorded with the
columns in order 4 5 3 6 2 1.
For the decryption, we set up a table with 6 characters in each row. Since the beginning
of the encrypted message came from the last column, we start writing the encrypted
message down the last column.
RHAVRHAV
The 5th column was the second one the encrypted message was read from, so is the
next one we write to.
TNUSRHAVTRNHUASV
AIERIKATREDESOQRTNUSRHAVAIRSTRIKEONHEADQUARTERSV
Unfortunately, since the transposition cipher does not change the frequency of
individual letters, it is still susceptible to frequency analysis, though the transposition
does eliminate information from letter pairs.