Question: Encryption/Decryption Skills/Knowledge: The main topics covered/required by this assignment are: Functions Arrays C-style Strings Basic I/O Task: You will first prompt the user for an

Encryption/Decryption

Skills/Knowledge: The main topics covered/required by this assignment are:

  • Functions
  • Arrays
  • C-style Strings
  • Basic I/O

Task: You will first prompt the user for an input string, call your encryption algorithm, and then print out the encrypted result to the user. To keep things simple, we will follow a simple algorithm for encryption. A C string will be scrambled by alternating characters from the end and then the beginning of an array. Consider the example below:

Index 4 (the last letter of the string in this example) is first moved to index 0 of the encrypted string. Next, index 0 of the original string is moved to index 1 of the encrypted string. Index 3 of the original string is moved to index 2 of the encrypted string. This continues until the entire string has been encrypted.

NOTE: You will need to be moving from both ends of the original string, but make sure you don't cross over!

At a minimum, you will need to implement the following functions:

  • int length(const char input[]); - This function should return the length of the c string input
  • void encrypt(const char original[], char encrypted[]); - This function will encrypt original following the algorithm outlined above, placing the encrypted c string into encrypted.

A sample run of your program should look like this:

Enter string for encryption: Hello CSCI 222! Your encrypted string: !H2e2l2l oI CCS

  • Make sure you use no libraries other than iostream
  • Make sure all your array sizes are declared using a symbolic constant.
  • You will need to create 2 C-style strings in main() for the base assignment.
  • Make sure test with input strings of both odd and even length!
  • Prototype before main(), implement after!

2. Create an additional decrypt(const char input[], char decrypted[]); Because we used a well-defined pattern to create our encrypted messages, it should be possible to reverse the process to decrypt the encrypted messages.

3. Our encryption alone is very simple. To add complexity, perform a ROT-13 (Wiki Page) after running your encryption function.

Index 0 1 2 3 4 5 Data HELLOVO DataOH LELO Index 0 1 2 3 4 5

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!