#include <cstdlib>
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main(int argc, char *argv[])
{
lagi:
char plain[100];
char chiper[100];
int key;
int pilih;
cout << "Masukkan Pillihan " << endl;
cout << "1. Enkripsi" << endl;
cout << "2. deskripsi" << endl;
cout << "Masukkan sidini : ";
cin >> pilih;
if(pilih=1){
cout << "Enkripsi " << endl ;
cout << "Masukkan kata : ";
cin >> plain;
cout << "Masukkan Key nya : ";
cin >> key;
for(int i=0;i<strlen(plain);i++){
//cout << plain[i] << "(" << int (plain[i]) << ")";
chiper[i]=((plain[i]+key)%128);
}
for(int i=0;i<strlen(chiper);i++){
cout << endl;
cout << chiper[i];
cout << endl;
}
}
else{
cout << "Deskripsi :" << endl ;
cout << "Masukkan kata : ";
cin >> plain;
cout << "Masukkan Key nya : ";
cin >> key;
cout << "Enkripsi :" ;
for(int i=0;i<strlen(chiper);i++){
//cout << chiper[i] << "(" << int (chiper[i]) << ")";
plain[i]=((chiper[i]-key)%128);
}
for(int i=0;i<strlen(plain);i++){
cout << endl;
cout << plain[i];
cout << endl;
}
}
/*cout << "Pilih lagi?? " << endl;
cout << "tekan y jika Ya, tekan n jika tidak " << endl;
char a;
char y, Y;
cin >> a;
if(a==y||a==Y){
goto lagi;
}
else{
cout << "terima kasih" << endl;
system("PAUSE");
return EXIT_SUCCESS;
}*/
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar