Hi,
Thank you for helping with this. I basically have to encrypt a file in where the user enters the file name & enters a name for the output file. The encryption is based on the password the user enters. It is a case situation, that being said, if the user decides to decrypt, the names output file must be used. I already have the code ready to go for the encryption & decryption, I just can't figure out how to pull the file from just a name the user enters (I'm thinking pointers will have to be used somehow...). Likewise, I will need to be able to save an output file that is encrypted & if the user desires, to decrypt that as well.
Below are the two functions I have created, one for encrypting, one for decrypting. I can post the whole program but figured it wasn't necessary (is available upon request though!). The encryption works now, my last feat is to get the files working. Any criticism/help is appreciated.
void encrypt(int choice)
{
//declare variables//
char pw[20], name[20];
int a,b,x,y;
cout<<"Please enter your first name:\n";
cin>>name;
//prompt for password//
cout<<"Please enter your password:\n";
cin>>pw;
x=strlen(name);
y=strlen(pw);
for(a=0,b=0; a<x; a++,b++){
if (b>=y)
b=0;
name[a]=name[a]+pw[b];
}
cout<<endl<<name;
cout<<endl;
cout<<"Encryption is finished!\n";
exit (0);
}
void decrypt(int choice)
{
//declare variables//
char pw[20], name[20];
int a,b,x,y;
cout<<"Please enter your first name:\n";
cin>>name;
//prompt for password//
cout<<"Please enter your password:\n";
cin>>pw;
x=strlen(name);
y=strlen(pw);
for(a=0,b=0; a<x; a++,b++){
if (b>=y)
b=0;
name[a]=name[a]-pw[b];
}
cout<<endl<<name;
cout<<endl;
cout<<"Decryption is finished!\n";
exit (0);
}