Question: PLEASE HELP! I am trying to create RSA program in C++ to encrypt data entered by the user. I have a few syntax erros. Here
PLEASE HELP! I am trying to create RSA program in C++ to encrypt data entered by the user. I have a few syntax erros.
Here is what I have so far :
#include
#include
using namespace std;
int main()
{
int ch, n, i
char s1[50], s2[50], key;
cout << "Please type your message: ";
cin.getline(s1, 50);
do
{
cout << " <<<>>> 1]Encrypt 2]Decrypt]n3]Exit Enter your choice: ";
cin >> ch;
switch (ch)
{
case 1: cout << "Enter the key character to encrypt data: ";
cin >> key;
for (i = 0; sl[i] != '\0'; i++)
{
s2[i] = s1[i] ^ key;
}
s2[i] = '\0';
cout << "Your data encrypted successfully Your secure character key is " << key;
cout << "Your encrypted data is --- " << s2;
break;
case 2: cout << "Enter the key character to decrypt data: ";
char t;
cin >> t;
if (key == t)
{
for (i = 0; s2[i] != '\0'; i++)
{
s2[i] = s2[i] ^ key;
}
cout << "Your decrypted data is " << s2;
}
else
cout << "Invalid character key ";
break;
case 3:break;
default:cout << "Invalid choice, try again ";
}
}while (ch != 3);
}
system("pause");
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
