Home » , » Description and Encription Program

Description and Encription Program

Posted by Agus Nur Ikhsan on Minggu, 20 November 2011

My program …
1 #include <cstdlib>
2 #include <iostream>
3
4 using namespace std;
5 class mtk{
6       private:
7               char plain[128],chiper[128];
8               int key,p, i,j;
9       public:
10              void in();
11              void encrip();
12              void deskrip();
13              };
14 void mtk::in(){
15     cout<<”masukan key : “;
16     cin>>key;
17     cout<<”masukan karakter : “;
18     cin>>plain;
19     p=strlen(plain);}
20 void mtk::encrip(){j=0;
21
22     for (i=1;i<=p;i++){
23     *chiper=(plain[j]+key)%128;
24     cout<<chiper;j++;
25 }}
26 void mtk::deskrip(){j=0;
27     for (i=1;i<=p;i++){
28     *chiper=(plain[j]-key)%128;
29     cout<<chiper;j++;
30 }}
31
32 int main(int argc, char *argv[])
33 {
34     mtk a;
35     a.in();
36     cout<<”encrip : “;
37     a.encrip();
38     cout<<endl<<”deskrip : “;
39     a.deskrip();
40     cout<<endl;
41     system(“PAUSE”);
42     return EXIT_SUCCESS;
43 }

This is the explanation from that program:
  • In step 5 I give “class mtk” for the name class.
  • I declared the private first in step 7 and 8.
  • Then the public in step 10 to 12.
  • The attribute and formula for description and encryption in this program there was in steps 14 to 30.
  • In step 29 to 40 is the execution for operator overloading.
  • Main function in step 32.
  • The class name n object called by steps 35 to 40.
Come on to display the output…

Thanks for reading & sharing Agus Nur Ikhsan

Previous
« Prev Post

0 komentar:

Posting Komentar

Popular Posts