# Coursework 2

## Rail fence cipher: exercises

Decrypt the following ciphertext that was generated using a rail fence cipher with 2 rails.

``1TEETN WRTRA HNWSE EOEBA TUSHR ISHBS KONOO MCIEA DVLPD YRHRC EBU``
1. Count characters and divide by 2 to get split point. 53/2 = 26.5, so split at H.
``````1T E E T N W R T R A H N W S E E O E B A T U S H R I S
2 H B S K O N O O M C I E A D V L P D Y R H R C E B U
``````
1. Gives: `THE BEST KNOWN ROTOR MACHINE WAS DEVELOPED BY ARTHUR SCHERIBIUS`

Use a rail fence cipher with 3 rails to encipher this message: `alan turing the enigma`.

``````1A  N  R  G  E  I  A
2 L  T  I  T  E  G
3  A  U  N  H  N  M
``````

Gives: `ANRGEIALTITEGAUNHNM`

## A more complex transposition cipher: exercise

As in the slides of the lecture, write the plaintext message: `The enigma cipher machine had the confidence of German forces who depended on its security` in a rectangle, row by row, and read the message off column by column but permute the order of the columns using the key `3571426`

3571426
theenig
maciphe
rmachin
confide
nceofge
rmanfor
ceswhod
epended
onitsse
curityx
``````1Columns:
23. tmrecnrceoc
35. hamhocmepnu
47. ecaaneaseir
51. eicdfonwnti
64. nphtiffhdst
72. ihihdgooesy
86. geneeerddex
9
101. eicdfonwnti
112. ihihdgooesy
123. tmrecnrceoc
134. nphtiffhdst
145. hamhocmepnu
156. geneeerddex
167. ecaaneaseir
``````

Encrypted with `3571426`:

``1eicdfonwntiihihdgooesytmrecnrceocnphtiffhdsthamhocmepnugeneeerddexecaaneaseir``

#### Second transposition with the same key

3571426
eicdfon
wntiihi
hdgooes
ytmrecn
rceocnp
htiffhd
sthamho
cmepnug
eneeerd
dexecaa
neaseir
``````1Columns:
23. ewhyrhscedn
35. indtcttmnee
47. ctgmeiheexa
51. diorofapees
64. fioecfmnece
72. ohecnhhurai
86. nisnpdogdar
9
101. diorofapees
112. ohecnhhurai
123. ewhyrhscedn
134. fioecfmnece
145. indtcttmnee
156. nisnpdogdar
167. ctgmeiheexa
``````

Encrypted with `3571426`:

``1diorofapeesohecnhhuraiewhyrhscednfioecfmneceindtcttmneenisnpdogdarctgmeiheexa``

## The `ADFGVX` cipher: exercise

Consider again the arrangement:

A8P3D1N
DLT4OAH
F7KBC5Z
GJU6WGM
VXSVIR2
X9EY0FQ

and encrypt: `The quick brown fox jumps over the lazy dog` first with the key `MARK` and then with the key `TURING`.

Stage 1:

``````1T  H  E  Q  U  I  C  K  B  R  O  W  N  F  O  X  J  U  M  P  S  O  V  E  R  T  H  E  L  A  Z  Y  D  O  G
2DD DX XD XX GD VG FG FD FF VV DG GG AX XV DG VA GA GD GX AD VD DG VF XD VV DD DX XD DA DV FX XF AG DG GV
``````

Stage 2:

``````1M A R K
2-------
3D D D X
4X D X X
5G D V G
6F G F D
7F F V V
8D G G G
9A X X V
10D G V A
11G A G D
12G X A D
13V D D G
14V F X D
15V V D D
16D X X D
17D A D V
18F X X F
19A G D G
20G V
``````
``````1A K M R
2-------
3D X D D
4D X X X
5D G G V
6G D F F
7F V F V
8G G D G
9X V A X
10G A D V
11A D G G
12X D G A
13D G V D
14F D V X
15V D V D
16X D D X
17A V D D
18X F F X
19G G A D
20V   G
``````
``1DDDGFGXGAXDFVXAXGV XXGDVGVADDGDDDVFG DXGFFDADGGVVVDDFAG DXVFVGXVGADXDXDXD``

## Feistel Encryption/Decryption: exercise

Show that output of decryption round 13 is equal to 32-bit swap of input to encryption round … (first identify the corresponding encryption round and then prove the equivalence).

Given:

• .
• Encryption: and .
• Decryption: and .

We want to show that .

Encryption:

Decryption:

Hence: .