Project Alternative
Project Alternative
Project Description: There is often a need to send across information in a secure way to
avoid eavesdropping by other people. Encryption is the most common way to scramble the
message intended to send with a shared secret key. The sender uses the secret key to encrypt
the message, called the plaintext, into the incomprehensible ciphertext for sending. The
receiver uses the same secret key to decrypt the received ciphertext to recover the original
plaintext message. In this project, you are to implement some of the common but simple
algorithms to perform encryption and decryption, given a key. It can be assumed that the text
consists only of English letters, numbers, and punctuations.
Objective: The primary objective of this project is to build a few functions for carrying out
encryption and decryption based on a secret key. A small program consisting of a menu can
be built to connect the functions together for simple practical usage.
Project Overview:
The first step to do the project is to understand the simple encryption and decryption
algorithms. For each algorithm, two related functions are defined as the next step with the
data and key as the input parameters. One function is to carry out the encryption and the other
decryption. Each function will return the ciphertext and recovered plaintext respectively. In
the final step, a simple program is developed accepting user inputs from the keyboard or from
files, and carry out the selected functionality.
Instructions:
Expected Outcomes:
By the end of this project, you should:
- Gain hands-on experience in the development of a medium-sized program that
supports a variety of functionalities in an organized manner.
- Understand how to apply programming techniques to solve small-scale practical
problems.
- Develop skills in simple analysis with different testing data.
- Learn to document the methodology and findings clearly and effectively.
Conclusion:
This project aims at developing a program to allow users to encrypt and decrypt their data
using a few common and simple encryption algorithms. You will enhance your programming
ability by designing a well-documented program with proper design and organization. By
following the outlined steps and utilizing the provided code structure, you will successfully
complete the project to yield a usable program for other users. For any questions or further
assistance, feel free to reach out!
Caesar’s Cipher
Please refer to Slide 77 to 79 in Lecture 7 for explanation. The encryption function in the
slide can only handle upper case letters, but the decryption function in the slide can handle
also upper case letters. You can compare the functions to gain your knowledge.
Substitution Cipher
The following shows a table of letter mapping from plaintext to ciphertext. A plaintext
message will be converted into ciphertext based on the mapping table. Here is a typical
mapping table, based on the simple keyboard order (which can be easily guessed).
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
q w e r t y u i o p a s d f g h j k l z x c v b n m
Following the table above, “hello” will be encrypted into “itssg” and “vgksr” will be
decrypted back into “world”.
Transposition Cipher
The following shows how a message is converted into ciphertext. It involves writing plaintext
in rows and reading out the ciphertext in columns. For example, assuming that we use N = 3
columns to encrypt the plaintext message “hellohowdoyoudo” (left hand side), we write
the letters horizontally and read them out vertically in column. We then get the ciphertext as
“hlooueowydlhdoo”. Note that there is normally no space in the plaintext or ciphertext,
to reduce the chance that someone can break the ciphertext at the space location. Similarly,
we can get the ciphertext in case that some columns are not full (right hand side).
h e l h e l
l o h e o w
o w d hlooueowydlhdoo o r l hlodeeorblwly
o y o d b y
u d o e
Decrypting the message will involve a reversed procedure as above. Given ciphertext
“hlooueowydlhdoo” with N = 3 columns, you will fill in every five letters (15/N = 5) in
the ciphertext in each column: column 1, then 2, then 3. The plaintext can then be read out
horizontally. Likewise, you can recover “helloworldbye” from “hlodeeorblwly”.
However, care must be taken as to handle the slightly shorter columns (in this case, column 2
and column 3) in this case.
A more secure transposition cipher allows a column reading order as part of the key. Using
the example above, assuming that we use N = 3 columns to encrypt the plaintext message
“hellohowdoyoudo”, we write the letters horizontally and read them out vertically in a
column order as specified by the key, e.g. 2, 3, 1 (second column, followed by third column,
and then first column) as “eowydlhdoohloou” for the ciphertext. In this case, we can say
that the key is [3, (2, 3, 1)], or in other convenient form.
h e l
l o h
o w d eowydlhdoohloou
o y o
u d o
To decrypt, from the ciphertext “eowydlhdoohloou” with key [3, (2, 3, 1)], you will fill
in every five letters in the ciphertext in column order of 2, 3 and 1 respectively into the 5 x 3
matrix and then read out the letters horizontally as usual. It will be much more challenging if
some of the columns are not full.
How to Confuse Your Enemy: On Simple Encryption and Decryption Approaches
Here is a sample program for the main menu. In order to use this program, you have to define
the appropriate functions for encryption and decryption. Some samples are also shown here.
C: Caesar C: Caesar
S: Substitution S: Substitution
T: Transposition T: Transposition
Q: Quit Q: Quit
Please select algorithm: A Please select algorithm: t
Wrong choice, please try again Please enter transposition columns: 3
C: Caesar Please enter your data:
S: Substitution hereisanexample
T: Transposition E: encryption D: decryption: e
Q: Quit Encrypting 'hereisanexample' with key 3
Please select algorithm: C The ciphertext:
Please enter Caesar key (1 to 25): 5 heaxpeinalrseme
Please enter your data: C: Caesar
HelloWorld S: Substitution
E: encryption D: decryption: E T: Transposition
Encrypting 'Hello World' with key 5 Q: Quit
The ciphertext: Please select algorithm: T
CzggjRjmgy Please enter transposition columns: 5
C: Caesar Please enter your data:
S: Substitution HSAEAMRNPEELIXE
T: Transposition E: encryption D: decryption: d
Q: Quit Decrypting 'hsaeamrnpeelixe' with key 5
Please select algorithm: c The recovered plaintext:
Please enter Caesar key (1 to 25): 10 HEREISANEXAMPLE
Please enter your data: C: Caesar
xem QHU oek DEM? S: Substitution
E: encryption D: decryption: d T: Transposition
Decrypting 'xem QHU oek DEM?' with key 1 Q: Quit
0 Please select algorithm: t
The recovered plaintext: Please enter transposition columns: 4
how ARE you NOW? Please enter your data:
C: Caesar transpositioncipher
S: Substitution E: encryption D: decryption: e
T: Transposition Encrypting 'transpositioncipher' with ke
Q: Quit y 4
Please select algorithm: s The ciphertext:
Please enter your data: tsinhrptceaoiirnsop
here is an example C: Caesar
E: encryption D: decryption: e S: Substitution
Encrypting 'here is an example' with key T: Transposition
qwertyuiopasdfghjklzxcvbnm Q: Quit
The ciphertext: Please select algorithm: t
itkt ol qf tbqdhst Please enter transposition columns: 6
C: Caesar Please enter your data:
S: Substitution tarliehleepxioxfhtsnaoeigmrrsepct
T: Transposition E: encryption D: decryption: D
Q: Quit Decrypting 'tarliehleepxioxfhtsnaoeigmrr
Please select algorithm: S sepct' with key 6
Please enter your data: The recovered plaintext:
ol oz royyoexsz? thisisalongerexampleforciphertext
E: encryption D: decryption: d C: Caesar
Decrypting 'ol oz royyoexsz' with key qw S: Substitution
ertyuiopasdfghjklzxcvbnm T: Transposition
The recovered plaintext: Q: Quit
is it difficult? Please select algorithm: Q
Project Deliverables:
1. Final Report:
o You are required to write the report describing your program design, key data
structures, and how you tackle potentially difficult logic. Interesting findings
in program development or execution can be provided with explanations and
using examples.
o The report should be of at least 10 pages. It must adhere to a plagiarism
threshold of less than 30%, which can be checked on Blackboard or any third-
party website.
o The report should consist of the following subsections:
Abstract
Introduction
Program design
Implementation issues
Discussion and/or findings
Conclusion
Appendix (useful content not suitable to be placed in main text)
Ensure that each section is well-developed and contributes to the overall narrative of
your project.
o Your report will be evaluated based on the quality of your writing and the
attention given to formatting. For example: ensuring equations are written
neatly, all references, if any, adhere to a consistent and neat referencing style,
both in the reference section and throughout the report, etc.
2. Code Files:
o All relevant code files used should be submitted, ensuring reproducibility of
the results.
3. Formatted Documents:
o The final report should be submitted in .pdf format, with a consistent
formatting style. You can refer to popular journals for examples, e.g. papers
from IEEExplore or ACM Digital Library (both sites accessible via PolyU
library).
By following these guidelines, you will create a cohesive report that effectively documents
your development and communicates your findings.
Demonstration
You should make a video (in MP4 format) to introduce the application in brief (about 3 to 5
minutes max) and submit it together with the source code and the project report on or before the
due date on the Blackboard. If your video is large size or due to any reason is not uploaded to the
blackboard then you should upload it elsewhere and share the link (you should ensure that the
video link has open shared access and not restricted to the instructors and the TA’s.)
Marks distribution
The mark distribution of this project is as follows:
Implementation: 65 %
Documentation: 30 %
Demonstration: 5 %
Bonus: 10 Points
Submission
You must submit the following files (except Item 4) in ONE zipped file and upload it to the
Blackboard System:
1. Readme file – write down your project title and the name of each member in your group,
together with all necessary information that may be required to run your program; name the
file as "Readme_Gxx.txt" where "Gxx" is your Group number assigned.
For BONUS points: You should clearly state what extra modules and components you have
implemented.
4. Name the demo video file as "demo_Gxx.mp4" (Use MP4 format for your video. If the
file size of the video is too large, send us a link to download it.)