1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
rjkz [21]
3 years ago
8

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 as the only thing on a line, 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. Then go back and request another string.
Computers and Technology
1 answer:
dem82 [27]3 years ago
3 0

Answer:

C++ code for encryption is given below

Explanation:

#include <iostream>

using namespace std;

//functions to encrypt and decrypt

void encrypt(char str[]);

void decrypt(char str[]);

int main(){

char str[200];

bool done = false;

while(!done){

cout << "Enter a string (enter * to stop): ";

cin.getline(str, 200);

if(str[0] == '*' && str[1] == '\0')

done = true;

else{

encrypt(str);

cout << "Encrypted: " << str << endl;

decrypt(str);

cout << "Decrypted: " << str << endl;

}

cout << endl;

}

}

void encrypt(char str[]){

int i = 1;

for(int j = 0; str[j] != '\0'; j++){

str[j] += i;

i++;

if(i == 11)

i = 1;

}

}

void decrypt(char str[]){

int i = 1;

for(int j = 0; str[j] != '\0'; j++){

str[j] -= i;

i++;

if(i == 11)

i = 1;

}

}

You might be interested in
If given program is executed, what will be output?
iogann1982 [59]

Answer:

16 22 399 214 351

Explanation:

es 1 .22 399 480

3 0
1 year ago
Which is the best method of marketing a game to casual players?
Phoenix [80]
A casual game is a video game targeted at or used by casual gamers. Casual games may exhibit any type of gameplay or genre. They are typically distinguished by simple rules and by reduced demands on time and learned skill, in contrast to more complex hardcore games. They typically impose low production and distribution costs on the producer. Casual games are often played on a personal computer online in web browsers, but are also popular on game consoles and mobile phones.

Hope this helped. Have a great day! :D
3 0
3 years ago
Read 2 more answers
What kind of resources can we share over the network? Plzzzzzzzz help!!!!!!
lubasha [3.4K]

Sharing network resources requires abiding by certain constraints, as follows:

<span>Security: Organizations present ongoing opportunities for unauthorized shared resources. Security mechanisms should be implemented to provide efficient parameters.Compatibility: Various client-server operating systems may be installed, but the client must have a compatible OS or application to access shared resources. Otherwise, the client may encounter issues that create communication delays and requires troubleshooting.Mapping: Any shared OS hardware drive, file or resource may be accessed via mapping, which requires a shared destination address and naming conventions.<span>File Transfer Protocol (FTP) and File Sharing: FTP is not affected by shared resources because the Internet is FTP’s backbone. File sharing is an LAN concept.</span></span>
3 0
3 years ago
Read 2 more answers
The best advice for setting a study session is
ExtremeBDS [4]
To take breaks and not do all the work at once.
3 0
2 years ago
A_ is an object makerfirst program second object third class fourth method ​
liberstina [14]

Answer:

you will use the components object animator whether sjetchware or HTML

5 0
3 years ago
Other questions:
  • Which of the following is considered information?
    6·2 answers
  • A ____ instruction copies data bits to storage locations and can copy data between any combination of registers and primary stor
    11·1 answer
  • Your wearable device synchronized with your smartphone this morning when you turned it on, but the two devices no longer are syn
    14·1 answer
  • _____ can render data useless to unauthorized users who might have violated some of the database security layers.
    7·1 answer
  • For each 8-bit data frame the layer uses a generator polynomial G(x) = x4+x2+ x+1 to add redundant bits. What is the sequence of
    11·1 answer
  • Kelly is a college sophomore majoring in computer science. She is interested in gaining exposure to the most useful and current
    13·1 answer
  • Voice authentication requires speech to text capability Facial recognition may be used for authentication The human iris is uniq
    6·1 answer
  • Which is said to be ‘computer on a chip’ (a) Micro processors (b) Microcontrollers (c) Both (c) None of the above
    9·1 answer
  • You are comparing cryptographic solutions to implement at your organization. Which two items should you focus on when you are ev
    12·1 answer
  • Is it true that if the user log out the computer will turn off automatically​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!