The science of writing secret codes is called cryptography. For thousands of years cryptography has made secret messages that only the sender and recipient could read, even if someone captured the messenger and read the coded message. A secret code system is called a cipher.
In cryptography, we call the message that we want to be secret the plaintext. The plaintext could look like this:
Hello there! The keys to the house are hidden under the flower pot.
Converting the plaintext into the encoded message is called encrypting the plaintext. The plaintext is encrypted into the ciphertext.
The ciphertext looks like random letters, and we cannot understand what the original plaintext was just by looking at the ciphertext.
Here is the previous example encrypted into ciphertext:
Yvccf kyviv! Kyv bvpj kf kyv yfljv riv yzuuve leuvi kyv wcfnvi gfk.
But if you know about the cipher used to encrypt the message, you can decrypt the ciphertext back to the plaintext. (Decryption is the opposite of encryption.)
Many ciphers also use keys. Keys are secret values that let you decrypt ciphertext that was encrypted using a specific cipher.
Think of the cipher as being like a door lock. You can only unlock it with a particular key.
encrypt a message by taking each letter in the message (in cryptography, these letters are called symbols because they can be letters ( A-Z) ( a-z ), numbers( 0-9 ) , all symbols and replacing it with a “shifted” letter.
Using letters are , If you shift the letter A by one space, you get the letter B. If you shift the letter A by two spaces, you get the letter C. For example , this is a picture of some letters shifted over by three spaces.
The number of spaces you shift is the key in the Cipher. The example above shows the letter translations for the key 3.
If you encrypt the plaintext “Howdy” with a key of 3, then:
• The “H” becomes “K”.
• The letter “o” becomes “r”.
• The letter “w” becomes “z”.
• The letter “d” becomes “g”.
• The letter “y” becomes “b”.
The ciphertext of “Howdy” with key 3 becomes “Krzgb”.
We will keep any non-letter characters the same. To decrypt “Krzgb” with the key 3, we go from the bottom boxes back to the top:
• The letter “K” becomes “H”.
• The letter “r” becomes “o”.
• The letter “z” becomes “w”.
• The letter “g” becomes “d”.
• The letter “b” becomes “y”.
You will write a C program that accept a message and the word encrypt , decrypt , or exit ( not case sensitive ) . The program then will do the following :
- Encrypt a message – Enter a key and :
a. Count and display number of capital letters , Small letters , digits and symbols in the message.
b. Count number of characters in the message.
c. Convert all small characters to capital letters and vice versa the display the message.
d. Encrypt the original message
e. Concatenate the encrypted message with the original message
- Decrypt a message – Enter a key and :
f. Count and display number of capital letters , Small letters , digits and symbols in the message.
g. Count number of characters in the message.
h. Convert all small characters to capital letters and vice versa then Display the message.
i. Decrypt the original message.
j. Concatenate the decrypted message with the original message
- Exit the program. Terminate the program.
Anything else is incorrect.
Guideline:
1) Must use 2 dimensional array
2) key number must be between 1 and 93. Anything else should be rejected.
3) Must have one function for populating the 2d array and encrypting the message and all other functions.
4) Must have one function for populating the 2d array and perform the decrypting the message and all other functions.
5) Must pass parameters ( message and the key ) to encrypt or decrypt functions .
6) Must have one function to perform the validation
( encrypt , decrypt , exit and the key number ).
7) You may use the functions that are provided by C libraries when writing this program. 8) Your encryption / decryption arrays will contain the following characters and numbers in the that sequence.
A – Z followed by
a - z followed by
0 - 9 followed by the following symbols in
!
(exclamation mark)
"
(Quotation mark)
#
(Number sign)
$
(Dollar sign)
%
(Percent sign)
&
(Ampersand)
'
(Apostrophe)
(
(round brackets or parentheses)
)
(round brackets or parentheses)
*
(Asterisk)
+
(Plus sign)
,
(Comma)
-‐
(Hyphen)
.
(Full stop, dot)
/
(Slash)
:
(Colon)
;
(Semicolon)
<
(Less-than sign)
=
(Equals sign)
(Greater-than sign; Inequality)
?
(Question mark)
@
(At sign)
[
(square brackets or box brackets)
\
(Backslash)
]
(square brackets or box brackets)
^
(Caret or circumflex accent)
_
(underscore, understrike, underbar or lowline)
`
(Grave accent)
{
(curly brackets or braces)
-
(vertical bar, vbar, vertical line or vertical slash)
}
(curly brackets or braces)
~
(Tilde; swung dash)
9 ) Must place the following information on top left of the first page of your assignment as comments
NAME : ______________________ CS 4350 – Unix Systems Programming
Serial Number:
Group Number:
Assignment Number: ___________
Due Date: 3 / 4 / 2020
Sample Run
Welcome to cryptography
What would you like to do to a message? ( encrypt , decrypt, exit )
Enter your choice : nothing
Invalid message
What would you like to do to a message? ( encrypt , decrypt, exit )
Enter your choice : exit
XXXXXXX and YYYYYYY Security Systems 3-‐4-‐2020
Sample Run
Welcome to cryptography
What would you like to do to a message? ( encrypt , decrypt, exit ) Enter your choice : encrypt
Enter your message:
HG
Enter the key number (1-‐93)
100
Invalid Key Number
What would you like to do to a message? ( encrypt , decrypt, exit )
Enter your choice : exit
XXXXXXX and YYYYYYY Security Systems
3-‐4-‐2020
Sample Run
Welcome to cryptography
What would you like to do to a message? ( encrypt , decrypt, exit ) Enter your choice : encrypt
Enter your message:
HG
Enter the key number (1-‐93)
3
Number of Capital Letters: 2
Number of Small Letters: 0
Number of Digits : 0
Number of Symbols : 0
Number of Characters in the message : 2
Converting Letters : hg
The decrypted text is:
KJ
Concatenation of original and encrypted text : HGKJ
What would you like to do to a message? ( encrypt , decrypt, exit )
Enter your choice : exit
XXXXXXX and YYYYYYY Security Systems
3-‐4-‐2020
Sample Run
Welcome to cryptography
What would you like to do to a message? ( encrypt , decrypt, exit ) Enter your choice : decrypt
Enter the key number (1-‐93)
3
Enter your message:
VWDWH
Number of Capital Letters: 5
Number of Small Letters: 0
Number of Digits : 0
Number of Symbols : 0
Number of Characters in the message : 5
Converting Letters : vwdwh
Your encrypted text is:
STATE
Concatenation of original and encrypted text : VWDWHSTATE
What would you like to do to a message? ( encrypt , decrypt, exit )
Enter your choice : exit
XXXXXXX and YYYYYYY Security Systems
3-‐4-‐2020
Instructions :
1. Can work as a group of 2.
2. Must submit one file that contains all your source code.
3. The output must follow the sample run format.
4. You must upload your solution using TRACS – Make sure you include the above as comments in your program
Make sure that you name your homework document as follows :
ZS#HW3.c
Where ZS# is your serial number. For example , the file name should look something like : ZS50HW3.c
You must upload your programs no later than the starting of class time on the due date.
Everyone must upload the electronic version. No late assignments will be accepted..
You must also turn in hard copy of your source code no later than the due date / time . Please turn one hard copy / group . Should the hard copy consist of more than one
page , then , the hard copy must be stapled. if you are unable to turn in a printout during class, you can take the program to the computer science department and hand it to the front desk personal (Comal 211 ) before the deadline. Make sure that the front office stamps the program. Make sure that include the date and time. Finally ,make sure that they place the program in my mailbox. No late assignments will be accepted..
DO NOT slide your program under my office door – It will NOT be accepted
The following points will be deducted if :
• Compilation Errors, missing electronic copy , missing the hardcopy , not written in c programming language, using global arrays or variables ,
submitting .zip file, submitting files other than .c or .txt file … etc ( - 10 points )
• Logical Errors ( at least 1 points )
• Other ( at least 1 points ) if any of the following takes a place :
• Unable to read the source code due to unclear printing
• Incorrect Output format.
• Incorrect program file name.
• Hard copy is not stapled.
• More than one hard copy per group.
• Incorrect Style such as but not limited to Missing Header comments, missing footer comments, not replacing my name with your name, missing serial number , missing section number … etc.
• Not using at least 3 functions ( prototypes and definitions ) and not passing arrays and parameters to functions … etc