Introduction
In cryptography, a transposition cipher (also known as a permutation cipher) is a method of encryption which scrambles the positions of characters (transposition) without changing the characters themselves. Transposition ciphers reorder units of plaintext (typically characters or groups of characters) according to a regular system to produce a ciphertext which is a permutation of the plaintext.
There are multiple types of transposition ciphers, however for this challenge we will be focusing on columnar transposition ciphers. In a columnar transposition, 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 width of the rows and the permutation of the columns are usually defined by a keyword. For example, the keyword ZEBRA is of length 5 (so the rows are of length 5), and the permutation is defined by the alphabetical order of the letters in the keyword. In this case, the order would be "5 3 2 4 1".
For example, we can encrypt the message "THIS IS A SECRET MESSAGE" using the keyword "ZEBRA" as follows:
5 3 2 4 1
Z E B R A
---------
T H I S I
S A S E C
R E T M E
S S A G E
The ciphertext is then read off as:
ICEE ISTA HAES SEMG TSRS
In these tasks, the ciphertext will be given to you without spaces, along with the keyword used to encrypt the message. You will need to decrypt the message to find the answer.
Task 1
Using the keyword CAT, build an algorithm to decrypt the following ciphertext:
HOSPTBYOEDH!
The output should be in the form of a single string, with no spaces or punctuation.
Task 2
In a regular columnar transposition cipher, any spare spaces are filled with nulls. For this task, we will be using a modified version of the cipher, where the spare spaces are filled with the character "_" instead. Using the keyword CODE, build an algorithm to decrypt the following ciphertext:
TASEEEL_CII_HKA_
The output should be in the form of a single string, with no spaces or punctuation, and have any nulls ("_") removed.
Final Answer
The final answer is in the form of xxx-yyy, where xxx and yyy are the answers to the two tasks above.