Transposition Cipher

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Due 22/10/2019

You are going to implement a very old and basic cryptography algorithm. This algorithm
was used by the German military in World War 1. The system was regularly solved by the
French, naming it Ubchi, who were typically able to find the key in a matter of days after
a new one had been introduced. However, the French success became widely known and,
after a publication in Le Matin, the Germans changed to a new system on 18 November
1914.

DuringWorldWar II, an advanced version of this cipher was used by Dutch Resistance
groups, the French Maquis and the British Special Operations Executive (SOE). It was also
used as an emergency cipher for the German Army and Navy. Until the discovery of the
VIC cipher, this was generally regarded as the most complicated cipher that an agent
could operate reliably under difficult field conditions

Task 1. Cipher

You are going to implement the crypt, cipher operation as a method. This method will
take a String message and a key (also a String) and mix the order of letters. The message
is written out in rows of a fixed length, and then read out again column by column, and
the columns are chosen in some scrambled order. Both the length of the rows and the
permutation of the columns are usually defined by a keyword. For example, the word
ALBERT is of length 6 (so the rows are of length 6), and the permutation is defined by the
alphabetical order of the letters in the keyword. In this case, the order would be ”1 4 2 3
5 6”. Finally, the message is read off in columns, in the order specified by the keyword.
For example, suppose we use the keyword Albert and the message of Albert Einstein
"One cant learn anything so well as by experiencing it oneself". In a regular
columnar transposition, we write this into the grid as:

A L B E R T
1 4 2 3 5 6
O N E - C A
N T - L E A
R N - A N Y
T H I N G -
S O - W E L
L - A S - B
Y - E X P E
R I E N C I
N G - I T -
O N E S E L
F - - - - -

This results in;

ONRTSLYRNOFE--I-AEE-E--LANWSXNIS-NTNHO--IGN-CENGE-PCTE-AAY-LBEI-L-

Task 2. Decipher

You are going to implement decipher method which takes in a ciphered text (using the
method in the first task) and the key it is ciphered with to obtain the original message. To
decipher it, the recipient has to work out the column lengths by dividing the message
length by the key length. Then he can write the message out in columns again, and then
re-order the columns by reforming the key word.

When the above ciphered text is layed out into a 6 by 13 grid;

A B E L R T
1 2 3 4 5 6
O E - N C A
N - L T E A
R - A N N Y
T I N H G -
S - W O E L
L A S - - B
Y E X - P E
R E N I C I
N - I G T -
O E S N E L
F - - - - -

When the columns are reordered we get;

A L B E R T
1 4 2 3 5 6
O N E - C A
N T - L E A
R N - A N Y
T H I N G -
S O - W E L
L - A S - B
Y - E X P E
R I E N C I
N G - I T -
O N E S E L
F - - - - -

Reading in the written order we get;

One-cant-learn-anything-so-well-as-by-experiencing-it-oneself-----

You have two weeks for this assignment. Also there will be an automatic evaluation of
your codes for cheating. Similar codes can easily be detected, so don’t even submit a
code that you have taken from your friend. If cought this will result in 0 pts.

You might also like