English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

this program encrypts and decrypts messages, and the encryption/decryption has to be affected by a "shift" variable for example if the value of shift is 7, and k corresponds to 1, the encryption should be 8 instead of 1, and the decryption for k should be 8 and not 1.
i got the encryption down i believe, here is the decryption part:

void decrypt(){
cout<<"Enter a message to decrypt (0 to quit)"< int code;
cin>>code;
while (code!=0){
if (code==1) cout<<"k";
Followed by 26 more if statements

(will continue in additional details)

Additional Details
2 hours ago
(cont'd)
cin>>code;
}
return;
}




int main(){

int choice;
int shift = 7; // default shift
choice = menu();
while (choice != 3){
if (choice == 1){
cout << "Enter the 'shift' value: ";
cin >> shift;
encrypt(shift); }
else
decrypt();

cout< choice = menu();
}

return 0;
}

how do i get it to be affected by the shift variable, the thing is i dont think im allowed to add anything to decrypt()

2007-02-26 20:14:17 · 1 answers · asked by Alex P 2 in Computers & Internet Programming & Design

1 answers

Hmm... I think you can make shift as a global variable. Then, you can write the function decrypt() and use shift inside of it, as shift is global. Try doing that. I am pretty sure it will work.
Encrypt function is not passing the data to be shifted. It is only passing the shift variable. Use the same analogy in decrypt()

Hope this helps!
Good Luck!

2007-02-27 18:52:48 · answer #1 · answered by A.Samad Shaikh 2 · 0 0

fedest.com, questions and answers