I am trying to write a program that asks the user to enter a message, then asks the user to enter a password 1-100. Then it encrypts the message based on ASCII conversion table. I figured out how to make the program increment the encryption by 1, but I need it to increment the ASCII conversion by the password.
using namespace std;
void encrypt( char [],int ); // prototypes of functions used in the code
void decrypt( char * ePtr ,int);
int main( )
{
// create a string to encrypt
const int messege =100;
char string[messege];
int a;
cout<<"\n**** ENCRYPTER ****\n";
cout << "\nInsert the secret sentence: ";
cin.getline(string,messege);
cout<< endl;
cout<< "Insert the encrypting code (1-100): ";
cin>>a;
cout<<endl;
encrypt( string ); // call to the function encrypt( )
cout << "The encrypted sentence is: " << string;
decrypt( string );// call to the function decrypt( )
cout<<"\n\n\n**** DECRYPTER ****\n";
cout<<"\nInsert the code: ";
cin>>a;
cout << "\nThe decrypted sentence is: " << string << endl;
cout<<endl;
return 0;
}
//encrypt data
void encrypt (char e[],int)
{
for( int i=0; e[i] != '\0';++i)
++e[i];
} // encrypt