PROGRAM ENKRIPSI MENGGUNAKAN C++

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
  char kalimat[100];
 int temp_ascii,geser=3;

 cout<<"Masukan kalimat yang akan di enkript \t= ";
 cin.getline(kalimat,sizeof(kalimat));

 cout<<"Hasilnya adalah \t\t\t= ";

 for(int i=0;kalimat[i];i++)
 {
  temp_ascii=int(kalimat[i]);
  if(temp_ascii != 32)//mengecek apakah ada spasi
  {
   if((temp_ascii>=97) && (temp_ascii<=122))//inputan a-z
   {
    temp_ascii = 97 + (temp_ascii - 97 + geser + 26) % 26;
    cout<<char(temp_ascii);
   }
   else
   if((temp_ascii>=65) && (temp_ascii<=90))//inputan A-Z
   {
    temp_ascii = 65 + (temp_ascii - 65 + geser + 26) % 26;
    cout<<char(temp_ascii);
   }
  }
  else

  cout<<char(temp_ascii);
}
    system("PAUSE");
    return EXIT_SUCCESS;
}
Iklan

One comment on “PROGRAM ENKRIPSI MENGGUNAKAN C++

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s