Lecture 4
Lecture 4
04/29/2024
Eng. Mohamed Jaambiir
Computer System Security
COS-413
Lecture Four
Eng. Mohamed Jaambiir
2
In a transposition cipher, the order of the alphabets is re-arranged to obtain the cipher-
text.
In the rail fence cipher, the plain-text is written downwards and diagonally on
successive rails of an imaginary fence.
When we reach the bottom rail, we traverse upwards moving diagonally, after
reaching the top rail, the direction is changed again. Thus the alphabets of the
message are written in a zig-zag manner.
After each alphabet has been written, the individual rows are combined to obtain the
cipher-text.
Eng. Mohamed Jaambiir 04/29/2024
19
Rail Fence Encryption
For example, if the message is “GeeksforGeeks” and the number of rails = 3 then cipher is prepared as:
As we’ve seen earlier, the number of columns in rail fence cipher remains equal to
the length of plain-text message. And the key corresponds to the number of rails.
Hence, rail matrix can be constructed accordingly. Once we’ve got the matrix we can
figure-out the spots where texts should be placed (using the same way of moving
diagonally up and down alternatively ).
Then, we fill the cipher-text row wise. After filling it, we traverse the matrix in zig-
zag manner to obtain the original text.
*___*___*___*
_*_*_*_*_*_*
__*___*___*_
“GsGsekfrekeoe”
Eng. Mohamed Jaambiir 04/29/2024
23
The End
Eng. Mohamed Jaambiir 04/29/2024