0% found this document useful (0 votes)
57 views

Substitute Cipher

Uploaded by

koleci3781
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Substitute Cipher

Uploaded by

koleci3781
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Substitute cipher

Modular Math and the Shift Cipher


The Caesar Cipher is a type of shift cipher. Shift Ciphers work by
using the modulo operator to encrypt and decrypt messages. The
Shift Cipher has a key K, which is an integer from 0 to 25. We will
only share this key with people that we want to see our message.

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.

(A=0, B=1, C=2, ...,Y=24, Z=25)

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".

We give the message "DATG" to our friend.

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".

First, write down all the letters of the alphabet.


*Now we will decide a number for encryption. For example, it can
be 1,2,3... or -1,-2,-3 etc. We will be using "+2" for this example.
Now write the all alphabet again under the first one but shift it to
right 2 times and transfer surplus letters from the and to the head.

*If we were to encrypt the word "instructables" it would be


"glqrpsaryzjcq".

! Important ! : While we create the cipher we have used "+2" as key


but while decrypting it will be "-2".

Step 2: Using Words As Key

Instead of using numbers we can use words as keys.

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.)

If we were to make "POTATO" our key than it would be left "POTA"


and when you write rest of the alphabet without "P","O","T","A"
letters you will be able to encrypt and decrypt the letter. In that case
the word " instructables" will be "fkrsqutspoibr".

Step 3: Using Multiple Numbers As Keys


*Instead of using one number for whole letter you can use multiple.
For example if you take "123" as key -the number can be big as you
want- while encrypting "CAT", decryption will be "DCW".

*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:

There is a clue behind the bookshelf.

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:

aolyl pz h jsBl ilopuk Aol ivvrzolsm.


As an example of decrypting with Caesar cipher, assume that we have the
following ciphertext, and that the key is 6.

ZNK WAOIQ HXUCT LUD PASVY UBKX ZNK RGFE JUM


Because we know that the key is 6, we can subtract 6 places off each character
in the ciphertext. For example, the letter 6 places before "Z" is "T", 6 places
before "N" is "H", and 6 places before "K" is "E". From this, we know that the
first word must be "THE". Going through the entire ciphertext in this way, we
can eventually get the plaintext of:

THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

WTGT XH PCDIWTG BTHHPVT IWPI NDJ HWDJAS WPKT CD IGDJQAT QGTPZXCV LXIW ATIITG
UGTFJTCRN PCPANHXH

HERE IS ANOTHER MESSAGE THAT YOU SHOULD HAVE NO TROUBLE


BREAKING WITH LETTER FREQUENCY ANALYSIS

OCDN ODHZ OCZ HZNNVBZ XJIOVDIN GJON JA OCZ GZOOZM O,


RCDXC DN OCZ NZXJIY HJNO XJHHJI GZOOZM DI OCZ VGKCVWZO

THIS TIME THE MESSAGE CONTAINS LOTS OF THE LETTER T, WHICH


IS THE SECOND MOST COMMON LETTER IN THE ALPHABET

Transposition Cipher Techniques in


Cryptography
••
Transposition Ciphers are an essential part of cryptography that uses
systematic shuffling of plain text characters or bits to secure data by
altering their positions based on some defined way or algorithm.
Moreover, unlike substitutive codes where different letters substitute
others, in these, you just shift about original letters hence it does not at all
look like any message.
The utilization of these strategies in relatively primitive encryption
methodologies, which in their simplicity formed the basis for more
sophisticated forms of encoding is shown by other historical ciphers like
Rail Fence and Columnar Transposition. Columnar transpositions are still
being explored and employed today within complex systems. For instance,
such as those involving hierarchical structures that are meant to increase
message secrecy through extra levels of obscurity.
In this article, we will learn about techniques used to encrypt the message
earlier. This article will provide details about the Transposition Cipher
Technique. Then we are going to explore various types of Transposition
Cipher Technique.
Transposition Cipher Technique
The Transposition Cipher Technique is an encryption method used to
encrypt a message or information. This encryption method is done by
playing with the position of letters of the plain text. The positions of the
characters present in the plaintext are rearranged or shifted to form the
ciphertext. It makes use of some kind of permutation function to achieve
the encryption purpose. It is very easy to use and so simple to implement.
Types of Transposition Cipher Techniques
There are three types of transposition cipher techniques
• Rail Fence Transposition Cipher
• Block (Single Columnar) Transposition Cipher
• Double Columnar Transposition Cipher

Rail Fence Transposition Cipher


Rail Fence Transposition cipher technique is the simplest transposition
cipher techniqueits. It is also termed as a zigzag cipher. It gets its name
from the way through which it performs encryption of plain text. The steps
to get cipher text with the help of the Rail Fence Transposition
cipher technique are as follow-
Technique of Rail Fence Transposition Cipher
Example: The plain text is “Hello Krishna”
Now, we will write this plain text in the diagonal form:

Rail Fence Transposition Cipher


Now, following the second step we get our cipher text.
Cipher Text = “rsnelkiha”

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.

It uses a simple algorithm,

1. Writing down the plaintext message into a sequence of diagonals.


2. Row-wise writing the plain-text written from above step.

Example,

Let's say, we take an example of “INCLUDEHELP IS AWESOME”.

So the Cipher-text are, ICUEEPSWSMNLDHLIAEOW.

What is Rail Fence Cipher in Cryptography?


In Rail Fence Cipher, given a plain-text message and a numeric key then
cipher/decipher the given text using the Rail Fence algorithm.

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.

Rail Fence Cipher Encryption


In a transposition cipher, the order of the alphabets is mixed up or we can say
rearrange to obtain the cipher-text or encrypted text.
• In the rail fence cipher, the plain-text is written as zigzag way as firstly
go downward till the box is not end and diagonally on successive rails of
an imaginary fence.
• When we reach the bottom rail, we simply traverse opposite moving
diagonally, after reaching the top rail or top line, the direction is
changed again. Thus the alphabets of the plain text are written in a zig-
zag form.
• When all the alphabet is fill in the rail then the individual's rows are
combined together to give a ciphertext.

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.

And the cipher text became: "dnetleedheswlxftaax".

Rail Fence Cipher Decryption


As we have studied earlier, the number of columns in rail fence cipher remains
equal to the length of plain-text which we took. And the key remains the same
as in encryption to the number of rails.

• 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.

Second stage in decryption process,

Third stage in decryption process,

Forth and the final stage in decrption process,


Now, we read them as diagonally from top to bottom then bottom to top and
we get the plain text or the original text i.e. "THEY ARE ATTACKING FROM
THE NORTH".

Block (Single Columnar) Transposition Cipher


Block Transposition Cipher is another form of Transposition Cipher which
was used to encrypt the message or information. In this technique, first,
we write the message or plaintext in rows. After that, we read the
message column by column. In this technique, we use a keyword to
determine the no of rows.
• Step 1: First we write the message in the form of rows and
columns, and read the message column by column.
• Step 2: Given a keyword, which we will use to fix the number of
rows.
• Step 3: If any space is spared, it is filled with null or left blank or
in by (_).
• Step 4: The message is read in the order as specified by the
keyword.
Block Columnar Transposition Cipher
For example: The plaintext is “KRISHNA RANJAN”
Now we will write the plaintext in the form of row and column.
Cipher Text = IAN_RNANS_J_KHRA
Double Columnar Transposition Cipher
Double Columnar Transposition Cipher is another form of Transposition
Cipher Technique. It is just similar to the columnar transposition technique.
The main objective of using a Double Columnar Transposition Cipher is to
encrypt the message twice. It makes use of the Single Columnar
Transposition technique but uses two times. It can use the same or
different secret keys. The output obtained from the first encryption will be
the input to the second encryption.
• Step 1: First we write the message in the form of rows and
columns, and read the message column by column.
• Step 2: Given a keyword, which we will use to fix the number of
rows.
Double Columnar Transposition Cipher:Step 1
• Step 3: If any space is spared, it is filled with null or left blank or
in by (_).
Now applying keyword 2:
Double Columnar Transposition Cipher: Step 2
• Step 4: The message is read in the order in by the keyword.
Now apply step 3:
Double Columnar Transposition Cipher: Step 3
• Step 5: Then the output from the first encryption is input to the
second.
• Step 6: Now the message is read in Technique in the order
specified by the second keyword.
• EOEQGSGSEFEQKRKQ
Double Columnar Transposition Cipher: Step 4
The Cipher Text is: “S_J_IAN_RNANKHRA”
Conclusion
In conclusion, Transposition Cipher Techniques are the techniques which
are used for encryption of plaintext or messages. There are several types
of Transposition Cipher Techniques which include Rail Fence
Transposition Cipher, Block (Single Columnar) Transposition Cipher, and
Double Columnar Transposition Cipher. Each technique has its way of
encrypting the plaintext.
Frequently Asked Questions on Transposition Cipher
Techniques in Cryptography- FAQs
Name another term that is used for the Transposition technique
Another term used for Transposition technique is Translocation

Why do we use the Transposition Cipher technique?


Transposition Cipher Technique was used to pass on or transfer the
message to the intended users in such a way that no third party can have
access to the message.

Are block Transposition Cipher and Double Columnar Cipher


Techniques the same?
The Block Transposition Cipher includes encryption of the message only
once, but the Double Columnar Cipher Technique includes encryption of
messages two times to provide more security.

Who invented the Transposition Cipher technique?


During the 4th century, the Greeks invented the Transposition Cipher
techniques.

Write some applications of the in Cipher Technique?


Some applications of Transposition Cipher Techniques are following:
• Communications in military
• security of message
• Transfer of message to the intended user.

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

More From Britannica


cryptology: Transposition ciphers

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

A transposition cipher is one in which the order of characters is changed to obscure


the message.

An early version of a transposition cipher was a Scytale[1], in which paper was


wrapped around a stick and the message was written. Once unwrapped, the message
would be unreadable until the message was wrapped around a same-sized stick again.

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.

More complex versions of this rows-and-column based transposition cipher can be


created by specifying an order in which the columns should be recorded. For example,
the method could specify that after writing the message out in rows that you should
record the third column, then the fourth, then the first, then the fifth, then the second.
This adds additional complexity that would make it harder to make a brute-force
attack.

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

Writing out the message in rows of 5 characters:

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

We now record the columns in order 4 1 3 2 5:

SIDP BMKG YMNS UEAG OLEK

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

To decrypt a keyword-based transposition cipher, we’d reverse the process. In the


example above, the keyword MONEY tells us to begin with the 4 th column, so we’d
start by writing SIDP down the 4th column, then continue to the 1st column,
3rd column, etc.

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

Continuing, we can fill out the rest of the message.

AIERIKATREDESOQRTNUSRHAVAIRSTRIKEONHEADQUARTERSV

Reading across the rows gives our decrypted message:


AIRSTRIKEONHEADQUARTERSV

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.

You might also like