Encryptor/Decryptor based on Password

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.

Here is my code thus far.

#include <iostream>
#include <iomanip>
#include <cstdlib>

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

//decrypt data
void decrypt( char * ePtr,int )
{
for( ; * ePtr != '\0'; ++ ePtr ) --(* ePtr);
}

I found 2 errors in your program. This is how I fixed it:

encrypt( string,messege ); // call to the function encrypt( )

decrypt( string,messege ); // call to the function decrypt( )
Topic archived. No new replies allowed.