Clab
Final Project
C Programming Lab Wuhan University 2019
Final Project Wuhan University Clab 2019
1. Final Project Report
You are required to write an English report for your final project. The report will contribute to your final score. The report should explain all decisions you took to solve each step of the final project. Explain your thought process and justify why the decisions you took are meaningful. You will be rewarded for creative ideas or unique ideas. Thinking beyond what is required will earn you extra points. The report also needs to contain screenshots with explanations. Ensure that your reports format is decent.
2. Submission
2.1 Deadline:
The submission deadline is the 31st of December 2019 at 23:59 pm. Note that this deadline represents a hard deadline, which does not allow late submissions. If you encounter exceptional circumstances that prevent you from handing in your submission on time, contact me personally as early as possible.
2.2 Format:
Digital Report:
You are required to hand in your final project report in PDF format. Ensure that the filename is your student number.
Physical Report:
In addition to the digital report you are required to hand in a physical (printed) version of your report.
Important:
a) Make sure that the report contains your student number and name on the top of the first page.
b) Make sure that your report is stapled and does not contain loose sheets of paper
Digital Source-code:
Submit your source code digitally, whereas the filename is your student number: i.e.: studentnumber.c. Do NOT submit your compiled program (studentnumber.exe) or any other files of your project (studentnumber.obj, etc.)!
Libraries:
You are not allowed to make use of libraries that were not used in any of the labs or theory lectures. If you are unsure about whether you are allowed to use a library or function, ask before submitting your project!
Dr. Dominik Wurzer
1|Page
Final Project Wuhan University Clab 2019
3. Plagiarism
Plagiarism is the act of intentionally or unintentional act of taking someone elses work or ideas and passing them off as ones own. Plagiarism is considered to be a serious offence and will be punished heavily. All submission will be auto-checked using plagiarism detection software. When a case of plagiarism is detected. Both students, the one copying and the one who is copied will receive 0% and fail the final project, which inevitable also leads to failing the course.
Plagiarism includes but is not limited to:
copying others source-code
copying parts of others source-code
copying unique ideas of others
sharing unique or creative solution with others
Note: Discussing the final project for the purpose of understanding the requirements is fine. Discussing how to solve a problem with others may however account as plagiarism as the two solutions are likely to be similar in nature.
Note: copying parts of a program and re-formatting or re-write parts of it, is still considered to be plagiarism.
4. Project Background
You are hired at $3cur3, a local Wuhan startup, as a C programmer in their data security division. Your project manager entrusts you with the implantation of a data encryption tool. Data encryption represents an important product for $3cur3, which it licenses to governments, businesses and private individuals for which secure data is a fundamentally important topic. Data, which is stored and transmitted digitally, can easily be intercepted. Therefore, its necessary to ensure that important data is encrypted. Your project manager at $3cur3 puts you in charge of implementing a program that offers several different encryption algorithms (listed in the paragraphs below). A user should be able to select an encryption type and given a file, he should be able to encrypt or decrypt text messages.
Dr. Dominik Wurzer
2|Page
Final Project Wuhan University
Clab
5. Encryption Algorithms
$3cur3 applies 3 different encryption algorithms. The algorithms differ in complexity and security.
5.1 Caesar Cipher Shift-Encryption
2019
The Shift-Encryption represents one of the simplest possible encryption algorithms. The encryption goes back to the famous roman emperor Julius Caesar, who lived more than 2,000 years ago in what is now called Italy. Under his rule, messages in the roman military and government were encrypted using the Caesar Cipher, which is also known as a Shift-Encryption. The algorithm encrypts a text by shifting the characters by a certain number of steps in the alphabet.
The table above shows the translation of the normal alphabet to an alphabet that has been shifted by 2 steps. Each of the character is translated to the character that comes 2 places after it.
If we were to encrypt the string KILO with a 2-Shift-Encryption, you would end up with the string MKNQ.
5.2 Double-Shift-Encryption
The Double-Shift-Encryption is an extension of the Shift-Encryption. It builds upon the original encryption by shifting every second character into another direction.
alphabet
I
J
K
L
M
N
O
P
Shifted
K
L
M
N
O
P
Q
R
K
->
M
I
->
K
L
->
N
O
->
Q
alphabet
I
J
K
L
M
N
O
P
shift A
K
L
M
N
O
P
Q
R
alphabet
I
J
K
L
M
N
O
P
shift B
G
H
I
J
K
L
M
N
The two tables above show the translation of the normal alphabet to an alphabet that is shifted 2 steps to the right (shift A) and 2 steps shifted to the left (shift B). To encrypt a string using the Double-Shift- Encryption, every character is alternated translated using Shifted-A and Shifted-B.
Dr. Dominik Wurzer
3|Page
Final Project Wuhan University Clab 2019
K
->
M
I
->
G
L
->
N
O
->
M
If we were to encrypt the string KILO with a 2-2-Double-Shift-Encryption, you would end up with the string MGNM. The first character is translated using the Shift-A table, the second character is translated using the Shift-B table, the third character is translated using the Shift-A table and so on.
As you can see, the Double-Shift-Encryption makes it harder to break the code, as the encrypted character M could stand for a K or an O, depending on its position within the string.
5.3 Random-Cipher
The Random-Cipher differs from the previous two Shifting-Encryption. Instead of translating characters according to a fixed shift in the alphabet, each character is randomly assigned to another character. In other words the Random-Cipher does not shift any characters. Instead, the algorithms reads a cypher- table, which randomly assigns each character to another character. An example of a small cypher-table is shown here:
If we were to encrypt the string KILO using the Random-Cipher from the above table, we would end up with XAOQ.
The cypher-table is stored in a separate file, as it is required for the encryption and decryption of messages. Ordinary Shift-Encryption fail once the shift (i.e.: the number of times a letter is shifted in the alphabet) is found. This means that once you know the translation of a single character, you automatically know the translation of all characters. This problem does not arise in a Random-Cipher because the letters are assigned at random and therefore do not follow a pattern. A down-side of the Random-Cipher is that the translation table is needed if you want to decrypt messages. This requires a secure transmission of the translation table. If the translation table is discovered the encryption fails.
alphabet
I
J
K
L
M
N
O
P
rand
A
F
X
O
R
L
Q
W
K
->
X
I
->
A
L
->
O
O
->
Q
Dr. Dominik Wurzer
4|Page
Final Project Wuhan University Clab 2019
6. Implementation
Your task if to implement a program that uses the above introduced algorithms to encrypt and decrypt files. Note that the following depictions of the user interface are just sketches by your $3cur3 project manager. You should see them as a guideline but you are welcome to improve them to look prettier. Note that you are allowed to add functionality but not remove it.
6.1 Program flow Overview
When your program is started, the user should choose whether he wants to: a) encrypt a file
b) decrypt a file
c) change the encryption method
d) exit the program
The following depiction represents an example for how your programs main menu might look like.
============================== Welcome to $3cur3 encryption Program ==============================
1) Encrypt
2) Decrypt
3) Change Encryption Method 4) Exit
Current encryption method: shift-3 Make selection (1-4):
Dr. Dominik Wurzer
5|Page
Final Project Wuhan University Clab 2019
6.2 Change Encryption Method
Show the user a list of supported encryption algorithms including a short description for each of them. After the user chooses his encryption method, return to the main menu and tell him the current encryption methods name.
================================= select your $3cur3 encryption algorithm =================================
1) 2-Shift-Encryption 2) 3-Shift-Encryption 3) 3-2-double-shift 4) 5-3-double-shift 5) random-cypher
Current encryption method: shift-3 Make selection (1-5):
6.3 Data Encryption
After the user selected Encryption, he is required to input the name of the file he wants to apply the encryption algorithm to. For the sake of simplicity, we limit the file location to the same folder of the program. Encrypt the selected file with the selected algorithm and store the encrypted version in the same folder and same filename but with the file extension sec.
For example: If a user wants to encrypt a file called myFile.txt, he will end up with an encrypted file in the same folder called myFile.txt.sec.
Dr. Dominik Wurzer
6|Page
Final Project Clab
6.4 Program flow for data encryption:
1
Wuhan University 2019
2
============================== Encryption
==============================
Current encryption method: shift-3
Enter filename to encrypt or exit to return to the main menu:
============================== Welcome to $3cur3 encryption Program ==============================
1) Encrypt
2) Decrypt
3) Change Encryption Method
4) Exit
Current encryption method: shift-3 Make selection (1-4):
3
============================== File filename successfully encrypted ==============================
1) Encrypt
2) Decrypt
3) Change Encryption Method 4) Exit
Current encryption method: shift-3 Make selection (1-3):
Dr. Dominik Wurzer
7|Page
Final Project Wuhan University Clab 2019
6.5 Data Decryption
After the user selected Decryption, he is required to input the filename of the encrypted file. Then decrypt the selected file with the selected decryption algorithm and show the result on the screen. Ask the user if he wants to save the decrypted text to a file. If the user wants to save the decrypted text, save it to the same directory with the file extension .txt.
For example: If a user wants to decrypt a file called myFile.sec, he will end up with an encrypted file in the same folder called myFile.sec.txt.
Dr. Dominik Wurzer
8|Page
Final Project Clab
6.6 Program flow for data decryption:
1
Wuhan University 2019
2
============================== Decryption
==============================
Current encryption method: shift-3
Enter filename to decrypt or exit to return to the main menu:
============================== Welcome to $3cur3 encryption Program ==============================
1) Encrypt
2) Decrypt
3) Change Encryption Method 4) Exit
Current encryption method: shift-3 Make selection (1-4):
34
============================== Decryption
============================== XXX show decrypted message here XXX
Do you want to save the decrypted message? (Y/N):
============================== File filename successfully Decrypted ==============================
1) Encrypt
2) Decrypt
3) Change Encryption Method 4) Exit
Current encryption method: shift-3 Make selection (1-3):
You are allowed to extend the and change the layout of the program flow presented above but you are required to implement the same functionality.
Dr. Dominik Wurzer
9|Page
Final Project Wuhan University Clab 2019
7 Grading
The final project contributes 60% of your total C lab course. You are required to successfully implement the basic version of the final project to pass the course. Note its highly recommended to also implement the more advanced versions of the final project. In case a student only implements the basic version and his program fails in the automated test, he also fails the project.
7.1 Basic Version (60%)
Every student is required to implement the basic version to pass the final project.
The basic version includes a simple 2-Shift Encryption (Section 5.1) on a file. To encrypt a message, your program should shift each character in the alphabet two steps to the right. A->C, B->D,
Your program is required to include the following functionality:
Encryption:
1) Read a file by filename from the same directory.
2) Encrypt file by shifting all characters by 2 to the right.
3) Store encrypted file in the same directory and same filename but with file-extension .sec
Decryption:
1) Read an encrypted file by filename
2) Decrypt tile by shifting all characters by 2 to the left (C->A, D->B, )
3) Display the decrypted file to the screen.
4) Ask the user if he wants to save the decrypted file to the disk.
5) If user wants to save it, write the decrypted file to the disk and save it with the same filename in the same directory but with file extension .txt
6) Go back to the main menu
For the basic version your algorithm is expected to be able to encode and decode the following characters: a-z (lower-case) and 0-9. Note that they should warp independently from each other:
i.e.: y>a; z>b and 8>0; 9>1
Dr. Dominik Wurzer
10 | P a g e
Final Project Wuhan University Clab 2019
7.2 Advanced Version 1 (20%)
Implement a 3-2-double-shift algorithm described in Section 5.2. Your algorithm should have an A-shift that shifts all characters by 3 to the right (A->D, B->E, ) and a B-shift that shifts all characters by 2 to the left (A->Y, B->Z, C->A, D->B, ). Then encrypt and decrypt by alternating A-shift and B-shift. Ensure to always start with A-shift.
Your algorithm for the advanced version 1 is expected to encode and decode, upper and lower case letters, numbers. Note that they should wrap independently from each other.
7.2 Advanced Version 2 (20%)
Implement a Random-Cipher algorithm described in Section 5.3. This algorithm requires a cipher-table. This table holds the alignment of each letter in the alphabet with another random letter. The cypher- table needs to be stored in a file, to allow you the decrypt a message later on. Make sure that each letter pair is on a separate new line and the two letters should be separated by a blank.
Example of a cypher-table ag
bd
cy
dw
ea
fl
gp
When selecting the Random-Cipher algorithm in the main menu, your program should ask if you already have a cipher-table. In case the user has a cipher-table and provides its name, load it in your program. Otherwise, generate a new cipher table and save it to the same directory. Encrypt and decrypt message based on the cypher-table. Note that the cypher-table itself is required to decrypt a message. In practice, this requires a secure way of distributing the random-cypher. Since the encryption fails when the cypher-table is discovered.
7.3 Bonus
Come up with creative ideas to improve the presented encryption algorithms. You receive points for describing a unique or especially creative idea. You will receive additional points for implementing your idea and demonstrating that it works.
Please note that the encryption methods of this project are considered to be basic algorithms and seen as unsecure by todays encryption standards. Therefore, do not rely on them for encrypting confidential information in real life situations!
Dr. Dominik Wurzer
11 | P a g e
Reviews
There are no reviews yet.