Question: Pointer Exercise in C++: In this exercise, you will be given a key and a message encrypted using Vigenre Encryption . Your goal is to
Pointer Exercise in C++:
In this exercise, you will be given a key and a message encrypted using Vigenre Encryption. Your goal is to decrypt this message with the given key.
Input format:
- Key size
- Key chars (decimals representing ascii values)
- Message size
- Message chars (decimals representing ascii values)
Notes:
- All chars in key will only be lowercase alphabets
- In char array (char[]), there must be a \0 at the end (ascii = 0)
- The problem already added \0 at the end of key and message
How does Vigenre Encryption work?
- Message: This is an example case.
- Key: example
What about Decryption? Just change + to -
5 (Key) 100 101 109 111 0
136 Message (Encrypted) 94 94 94 32 70 115 122 117 117 101 102 105 111 101 102 119 114 114 101 33 32 94 94 94 10 77 114 121 32 98 111 118 119 32 102 118 104 32 104 113 97 114 46 10 84 120 115 100 119 113 32 98 100 113 113 32 109 114 121 100 32 116 108 112 113 32 119 113 32 120 116 115 32 105 115 100 97 100 120 32 97 116 32 118 120 103 114 104 114 112 87 71 95 80 77 80 49 49 46 102 116 98 44 32 10 111 113 104 32 101 105 101 113 117 104 32 108 120 32 102 99 32 72 51 44 32 120 116 111 113 111 101 32 58 41 0
You can refer to the code template below:
//Perform the Vingenere Decryption Algorithm void vigenereDecrypt(const char* ciphered_txt, char* original_txt, int size, const char* key, int key_size){ //iterate through every char, align char with corresponding key_char //if current char in lowercase then... //if current char in upper case, then.. //if current char is not an alphabet, then.. } int main(){ //read file //print key // print ciphered text // print original text return 0; } here's the input example and expected output:
8 (Key) 101 120 97 109 112 108 101 0
97 Message (Encrypted) 88 101 105 101 32 120 100 32 101 114 32 98 120 109 98 97 112 105 32 122 97 101 116 46 10 90 114 112 118 32 97 120 101 115 101 102 98 116 101 32 108 116 112 112 32 121 101 32 111 119 108 114 107 98 100 33 10 65 105 115 105 118 32 122 104 109 103 108 103 120 98 114 101 32 108 116 112 112 32 111 101 121 112 116 114 32 120 101 101 32 101 112 120 105 46 0
output:
KEY: ========================================================================================================== example ========================================================================================================== CIPHERED TEXT: ========================================================================================================== Xeie xd er bxmbapi zaet. Zrpv axesefbte ltpp ye owlrkbd! Aisiv zhmglgxbre ltpp oeyptr xee epxi. ==========================================================================================================
ORIGINAL TEXT: ========================================================================================================== This is an example case. Only alphabets will be changed! Other characters will remain the same. ==========================================================================================================
//end of output.
Output must follow this format.
Reminder: code in C++ only.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
