October 7th, 2013, 09:36 AM
Help with a Crypto Assignment...
Ok so the assignment is to understand another students cipher. Then decrypt the 3 cihpertexts at the end. Where I get lost is in the transpostion operation. I dont understand how the student got the values for the key and how to rearranged the letters?
Design a simple cipher that performs both substitution and transposition operations. Describe
how it works, and provide code (or pseudocode) for the encryption and decryption routines.
My simple cypher works by taking a key and utilizing it for both the substitution and transposition of
the clear text.
The keys that are used are the English language keys and the space character.
Each letter has a value starting with a=1 up to z= 26 and space that equals 0. Numbers could be
exchanged with letters for the same value. So a one will also be the same as an 'A'
The message must be a multiple of 5 characters, and if not, add random characters to the end until it is.
The first step in order to encrypt a message is the substitution.
The substitution is done by adding the first number value of the key into the first letter value of the
message. If the value goes over 26 it just wraps around back to zero.
The process is repeated with the next letter of the key with the next letter of the message, until the
entire text is substituted. If the length of the key is less than the text, then the key repeated from the
The next step is transposition.
This is done by using the values of each of the key letters.
The message is then arranged into blocks of 5 characters.
The key values are used to swap the places of the characters within the same block. Since they are
blocks of 5, the key values wrap to 1 when they go over 5. So A would have the value of 1, B 2, C 3, F
would be 1 once again.
The first character then swaps places with the place that the key is showing. If, it is a space, then no
swapping takes place.
For example the first character would swap places with the fourth character if the key value was a
four. This step is then used for the next character in line with the next key value. If you run out of key
values, then start over from the beginning of the key.
A simple example
The key is: K E Y
The message is: Secrets
The length of the message is adjusted with random characters:
S E C R E T S Y F U
Values are given to message characters:
S E C R E T S Y F U
19 5 3 18 5 20 19 25 6 21
11 5 25 11 5 25 11 5 25 11
11 5 25
The keys are added to the character values and the new letters are encoded:
3 10 1 2 10 3 3 3 4 5
C J A B J R C C D E
They are separated into groups of 5 and the values of the key are calculated:
K E Y
2 1 1
C J A B J
2 1 1 2 1
R C C D E
1 2 1 1 2
The values are swapped one by one using the key values as the position to swap:
J B C J A
D R C R C
This is the new cipher text: JBCJADRCRC
To decrypt it the steps are done backwards. Starting with transposition from the last character.
Here are 3 sample cipher text: