Question: A info sec class programming question in C++ We will practice the idea of encryption and decryption in this assignment based on string manipulation. Given

A info sec class programming question in C++

We will practice the idea of encryption and decryption in this assignment based on string manipulation. Given a string plaintext, it is encrypted as following:

plaintext is first shifted right length()/2 positions (toward higher index).

Next each letter is changed:

If an uppercase letter: 'A'->'Z', 'B'->'Y', ... 'M'->'N', 'N'->'M', ..., 'Y'->'B', 'Z'->'A'

If a lowercase letter: same idea as for uppercase letter. i.e. 'a' -> 'z', 'b'->'y', ..., 'y'->'b', 'z'->'a'

If a digit: same idea as for uppercase letter. i.e. '0' ->'9', '1'->'8', '2'->'7' ...

Anything else remains the same.

For example, given a plain text of Secret 12, its changed into:

original : Secret 12

encrypted: g 87hvxiv

// index: 0 1 2 3 4 5 6 7 8

// S e c r e t 1 2

// length is 9, so shift 4 times toward right (9/2 is 4, int division. If length is 10, should shift 5 times)

// After shifting:

t 1 2 S e c r e

// next change each character:

g 8 7 H v x i v

Your program should include at least the following:

One function to encrypt a given plain text string as explained above. It should return a string containing the corresponding cipher text.

One function to decrypt a cipher text that has been encrypted as explained above. This function should return the decrypted text as a string.

You may add additional function(s) which is(are) necessary for your design.

Include in your main() one or more testing cases, with each testing case tests both the encryption function and the decryption function as shown below:

std::string str = "Secret 12";

std::string secretStr = encrypt(str);

std::cout

std::cout

std::cout

A info sec class programming question in C++ We will practice the

original: Secret 12 encrypted: g 87Hvxiv decrypted: Secret 12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!