Disini saya akan membuat program ShiftChiper , yaitu program encrypt dan decrypt sederhana dengan menggunakan Borland C++ 5.02. Semoga bermanfaat ^_^
#include iostream.h;
#include stdio.h;
#include conio.h;
void encrypt(int shift);
int main(void)
{
int shift;
int decOrEnc;
cout<<"| ======================= |\n";
cout<<"| Program Encrpyt Decrypt |\n";
cout<<"| ======================= |\n";
cout<<"| By Yusuf Maulana P |\n";
cout<<"| ======================= |\n";
cout<<"Masukkan angka pergeseran : ";
cin>>shift;
if (shift < 0)
{
cout<<"Bad Input.";
getch();
return 0;
}
cout<<"Ketikkan 1 untuk encrypt atau 0 untuk decrypt : ";
cin>>decOrEnc;
if (decOrEnc != 0 && decOrEnc !=1)
{
printf("Bad Input.");
return 0;
}
while(getchar() != '\n');
if (decOrEnc == 1)
encrypt(shift);
else
{
shift = -1 * shift;
encrypt(shift);
}
getch();
return 0;
}
void encrypt(int shift)
{
char ch;
cout<<"Inputkan string : ";
ch = getchar();
while(ch != '\n')
{
if (ch == ' ')
{
putchar(ch);
}
if(shift == 1){
putchar(ch + shift);
}
else{
putchar(ch - shift);
}
ch = getchar();
}
putchar(ch);
}
Posting Komentar