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
Administrative activities, such as archiving project files, closing out contracts, documenting lessons learned, and receiving fo
asambeis [7]

Answer:

closing

Explanation:

6 0
3 years ago
When you sort a cell range using a to z or z to a, what is rearranged?
kvv77 [185]
Only those cells names. Most common mistake in excel. If you want to sort rows make sure you highlight everything and then use sort function on column
5 0
3 years ago
No spamming or links
Hitman42 [59]
I think the answer is true,
8 0
2 years ago
Read 2 more answers
What paper should I use for technical drawing?
Vitek1552 [10]

Answer:

classic A4 format, and therefore for 210 x 297 mm sheets

7 0
3 years ago
You are considering upgrading memory on a laptop. What are three attributes of currently installed memory that HWiNFO can give t
Dennis_Churaev [7]

Answer:

Some of the qualities of the installed memory which HWiNFO can reveal are:

  • Date of manufacture
  • Memory type
  • Speed of memory

Explanation:

HWiNFO is an open-source systems information app/tool which Windows users can utilize as they best wish. It helps to detect information about the make-up of computers especially hardware.

If you used HWiNFO to diagnose the memory, the following information will be called up:

  • the total size of the memory and its current performance settings
  • the size of each module, its manufacturer, and model
  • Date of manufacture
  • Memory type
  • Speed of memory
  • supported burst lengths and module timings,
  • write recovery time etc.

Cheers

6 0
3 years ago
Other questions:
  • 1- Design a brute-force algorithm for solving the problem below (provide pseudocode): You have a large container with storage si
    10·1 answer
  • What type of elements are bridges exposed to yearly
    13·2 answers
  • 4. The same data source can be used multiple times in creating mail-merge documents.
    7·1 answer
  • The network topology in which each device is connected directly to a central network switch
    9·1 answer
  • Describe how data center storage applications drive the development of SAN technology.
    8·1 answer
  • Suppose Host A wants to send a large file to Host B. The path from Host A to Host B has three links, of rates R1 = 500 kbps, R2
    14·1 answer
  • Mary can view the thumbnails of her presentation slides when she’s creating the slides which element of the programs interface i
    8·1 answer
  • 1. Trust can be built in a relationship if:
    15·1 answer
  • Overnight Delivery Service delivers a package to Pam. At the request of Overnight's delivery person, to acknowledge receipt Pam
    13·1 answer
  • If you said the bottom margin, you are talking about what?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!