University of Wollongong Singapore Institute of Management: School of Computing and Information Technology (SCIT)
University of Wollongong Singapore Institute of Management: School of Computing and Information Technology (SCIT)
Objectives
This assignment includes six tasks.
• At the top of your code, you will need to specify the version of the programming language that
you use.
1
• Students are to place all compilation and instructions on how to run the program inside a
README.TXT file. The markers will refer to this file when marking.
• Submission filenames are to be the same as the ones given in the assignment specifications, do
not use your own filenames.
• DO NOT post this assignment to any forum, or else you will receive 0 marks immediately.
• Apply cryptanalysis to each of Ctext-1 and Ctext-2. You can use the krypto program pro-
vided.
• Present a report describing what steps you took to break each cipher, and why. Justify choices
you have made.
• Provide the plaintext and key for each cipher. You should include them as files Ptext-1.txt,
Key-1.txt, Ptext-2.txt and Key-2.txt, and also give them in your report (Report1.pdf).
• If you use any other tools or software, you must cite them in your report.
• If you only provide the final answer but without any proper analysis, then you will obtain 0.
2
where the -e option is associated with encryption and the -d option is associated with decryption.
You may assume all input is lower case without punctuation. You should use the same convention
described in the lecture regarding the encryption of diagonally related plaintext pair elements.
Several things to note:
• Your program must be able to cope with special inputs, such as replacing ’i’ with ’j’ (or vice
versa) during the encryption/decryption
• When inserting additional characters during the encryption, you will need to remove them
during the decryption.
• To make your program more robust, you may add important information, such as the length
of the ciphertext. However, this should ensure that you will get the decryption process done
correctly.
• Generate the ciphertext file Ctext-3.txt obtained by encrypting Ptext-1.txt under the key
in keyfile.txt.
• In your report, describe the statistical properties of Ctext-3 and discuss how they compare
with those of Ctext-1 and Ctext-2, remembering that Ctext-1 and Ctext-3 are associated
with the same plaintext. Include a comparative graph of the letter frequency distributions.
Write your report in a file called Report2.pdf.
• Discuss a way to decrypt the Playfair cipher without using the key. Show your argument by
decrypting the ciphertext Ctext-3 assuming that you don’t know the key. The discussion will
need to be written in the same file Report2.pdf.
• To test the correctness of your program, one can just simply test with
where the keyfile.txt is in fact empty, and your program should do an automatic decryption
and verify whether the file Output.txt is identical with Ptext-1.txt by executing
in Unix/Linux.
3
3 Task Three: Affine Cipher (3 marks)
Consider the Affine Cipher on the alphabet Z26 = {A, B, . . . , Z} with the usual identification A = 0,
B = 1, . . . , Z = 25, and the encryption function with key (a, b):
C = aM + b (mod 26).
1. Which of the following keys are valid? and why? (0.5 marks)
(i) (3, 8) (ii) (8, 3) (iii) (5, 0) (iv) (0, 5) (v) (13, 1)
2. For each of the above valid keys, determine the decryption function formula. (Please show all
your working steps. Without any working steps then you will get 0.) (0.5 marks)
3. Implement the cipher using C++ or Java.
The program should be able to do both encryption and decryption. Lowercase characters
a-z will be encrypted/decrypted to lowercase characters. Uppercase characters A-Z will be
encrypted/decrypted to uppercase characters. Other characters not in the range (a-z,A-Z) will
be unchanged.
The program should accept the following parameters: a flag to indicate encryption or decryp-
tion, a secret key, an input file name, and an output file name. For example:
myProgram -key 3 8 -encrypt -in file1.txt -out file2.txt
myProgram -key 3 8 -decrypt -in file2.txt -out file3.txt
The program should be able to detect invalid key and display an error message if it encounters
an invalid key. (1.5 marks)
4. Test your program (both encryption and decryption) with the keys in question 1 in this part.
(0.5 marks)
4
5 Task Five: Is this an English text? (2 marks)
In this task, you are to write a program in C++/Java which accepts an input of a text file. Then
your program will need to determine whether the contents of that text file is written in English or
not. Essentially, what you will need to do is to determine the value of the Index of Coincidence.
However, you will need to remember that any monoalphabetic ciphertext will also carry the same
IC. A sample run of the program is as follows:
$ IsEnglish test.txt
This is not an English text.
The IC = 0.043
$ IsEnglish test2.txt
This is an English text.
The IC = 0.070
Submission
You need to submit one ZIP file and upload it to Moodle. In this ZIP file, you need to create six
subdirectories, in which each subdirectory will have the answer to each task. For each programming
task, write a README file that explains the compiler setting. Ideally, you should make a Makefile
for each of the tasks.
DISCLAIMER: This assignment contains an intellectual property that is owned by the University
of Wollongong. Please do not use it without the permission from the University of Wollongong. If
you have any questions, please contact the author on [email protected].
DISCLAIMER: By submitting your assignment, you DECLARE that the assignment is your
own work and you did not obtain it from any third party or even purchase it from someone else or
ask someone else to do it for you. If you violate this rule, then you may end up failing the subject
entirely.