Programming Assignment

A substitutional Vigenère square is a variance of Vigenère square combining with substitution cipher. The first row is a subsitution cipher code book and each of the following row is the cyclic left rotation of the row right on the top of it. An example of a substitutional Vigenère square is shown as the following:
Normal Letters A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher Letters N E I Q O Y A R D C S H X Z B P J T K U F L V G W M
Cyclic Left
Rotation of
the above Row
E I Q O Y A R D C S H X Z B P J T K U F L V G W M N
I Q O Y A R D C S H X Z B P J T K U F L V G W M N E
Q O Y A R D C S H X Z B P J T K U F L V G W M N E I
O Y A R D C S H X Z B P J T K U F L V G W M N E I Q
Y A R D C S H X Z B P J T K U F L V G W M N E I Q O
A R D C S H X Z B P J T K U F L V G W M N E I Q O Y
R D C S H X Z B P J T K U F L V G W M N E I Q O Y A
D C S H X Z B P J T K U F L V G W M N E I Q O Y A R
C S H X Z B P J T K U F L V G W M N E I Q O Y A R D
S H X Z B P J T K U F L V G W M N E I Q O Y A R D C
H X Z B P J T K U F L V G W M N E I Q O Y A R D C S
X Z B P J T K U F L V G W M N E I Q O Y A R D C S H
Z B P J T K U F L V G W M N E I Q O Y A R D C S H X
B P J T K U F L V G W M N E I Q O Y A R D C S H X Z
P J T K U F L V G W M N E I Q O Y A R D C S H X Z B
J T K U F L V G W M N E I Q O Y A R D C S H X Z B P
T K U F L V G W M N E I Q O Y A R D C S H X Z B P J
K U F L V G W M N E I Q O Y A R D C S H X Z B P J T
U F L V G W M N E I Q O Y A R D C S H X Z B P J T K
F L V G W M N E I Q O Y A R D C S H X Z B P J T K U
L V G W M N E I Q O Y A R D C S H X Z B P J T K U F
V G W M N E I Q O Y A R D C S H X Z B P J T K U F L
G W M N E I Q O Y A R D C S H X Z B P J T K U F L V
W M N E I Q O Y A R D C S H X Z B P J T K U F L V G
M N E I Q O Y A R D C S H X Z B P J T K U F L V G W

A keyword can be any English word, it will be repeatedly concantenate itself until the same length as the encoded text. The encoded text and the repeated keyword is algined and then a code to book is selected. Selection of the code book is to match the aligned letter of the keywork with the fist letter of the code book. With the selected code book, the letter of the encoded text is then translated to a ciphered letter. For example, if the keyword is "FENGCHIA" and the text is "STRUCTUREPROGRAMMINGDESIGNINC" (Structure Programming Design in C), the encoding of the text is shown as below.

Input Text S T R U C T U R E P R O G R A M M I N G D E S I G N I N C
Keyword F E N G C H I A F E N G C H I A F E N G C H I A F E N G C
Encoded Text X F T T H O V G W J Z X P I I K A C Z Q X P F B N B D S H

The encoded text is "XFTTHOVGWJZXPIIKACZQXPFBNBDSH". Write a C program to perform the following steps:

  1. Input a keyword and an English text;

  2. Remove white spaces and punctuation symbols;

  3. Convert all lower case letters to upper case letters;

  4. Encode the text using the Vigenère square with the code book given in the substitutional Vigenère square;

  5. Output the original text and the encoded text;

  6. Decode the encoded text and output the decoding result.

Assume the maximum characters in the input length is 10,000. You may use MDOS pipeline command to input (<) and output (>) the original text and the encoded text. In this assignment, you must submit two files: the source code of the solution assignment8_dxxxxxxx.c (80%) and the assignment report assignment8_dxxxxxxx.pdf (20%), where dxxxxxxx is your student ID. The assignment report should explain the encoding algorithm and decoding algorithm in steps iv and vi, write pseudo code, and draw flowchart of your solution.  Also, include program comments in the source code.

Sample input C_Programming.txt and sample output:

Another sample input MacArthur_Prayer1.txt and sample output: