Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that encrypts and decrypts a string of characters. Use a char array for this, not the string class. The maximum length of

image text in transcribed
Write a program that encrypts and decrypts a string of characters. Use a char array for this, not the string class. The maximum length of a string input to the program will be 200 characters. The input may contain blanks and other whitespace. Your program must request a c-string from the user and encrypt it as described below. If the user enters a single asterisk, the program should stop. Otherwise, encrypt the string, then display the encrypted version. Decrypt it using the inverse of the algorithm below and display the result. This should be the original string. Write a function that performs simple encryption on an array of characters. The encryption algorithm is to add 1 to the first character, 2 to the second, and so on up to 10 to the tenth character. Then add 1 to the 11th character, 2 to the 12th character, and so on. That is, the first, eleventh, 21st and so on characters are incremented by 1, the second, twelfth, 22nd, and so on characters are incremented by 2, etc. Remember how c-strings are stored in memory. Your function should work with any length string. The parameter is the char array and there is no return value; the array you pass will be modified by your function. (This algorithm should look familiar.) To decrypt, subtract 1 from the first character, 2 from the second, and so on, up to subtracting 10 from the 10th character, 1 from the 11", and so on For example, if you entered the string ABC, the output from encryption would be BDF and the result from decryption would be the original string, ABC

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions