0% found this document useful (1 vote)
2K views9 pages

Aplikasi Kriptografi Menggunakan Visual Basic 6

This document contains the source code for an encryption and decryption program written in Visual Basic 6.0. It includes subroutines for encrypting and decrypting text using a keyword or key, along with the textbox names and button names used to run the program. The code takes each character of the plaintext, encrypts it by adding or subtracting the corresponding character in the keyword, and displays the encrypted ciphertext.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
2K views9 pages

Aplikasi Kriptografi Menggunakan Visual Basic 6

This document contains the source code for an encryption and decryption program written in Visual Basic 6.0. It includes subroutines for encrypting and decrypting text using a keyword or key, along with the textbox names and button names used to run the program. The code takes each character of the plaintext, encrypts it by adding or subtracting the corresponding character in the keyword, and displays the encrypted ciphertext.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

Aplikasi Kriptografi Menggunakan Visual Basic 6.

Kode Listing Program :


Sub dekrip()

On Error Resume Next

Text1.Text = ""

a = Len(chiper.Text)

c=1

For i = 1 To a

b = Asc(Mid(UCase(hasil.Text), i, 1))

If b > 64 And b < 123 Then

If c > Len(kunci.Text) Then

Do

c=c-1

Loop Until c = 1
Else

End If

d = Asc(Mid(UCase(kunci.Text), c, 1))

e = b - (d - 65)

If e < 65 Then

g = 91 - (65 - e)

Else

g=e

End If

f = Chr(g)

c=c+1

Else

f = Chr(b)

End If

Text1.Text = Text1.Text + f

If LCase(hasil.Text) = hasil.Text Then

Text1.Text = LCase(Text1.Text)

Else

End If

Next i

End Sub

Private Sub Command1_Click()

On Error Resume Next

hasil.Text = ""

a = Len(chiper.Text)

c=1
For i = 1 To a

b = Asc(Mid(UCase(chiper.Text), i, 1))

If b > 64 And b < 123 Then

If c > Len(kunci.Text) Then

Do

c=c-1

Loop Until c = 1

Else

End If

d = Asc(Mid(UCase(kunci.Text), c, 1))

e = b - (d - 65)

If e < 65 Then

g = 91 - (65 - e)

Else

g=e

End If

f = Chr(g)

c=c+1

Else

f = Chr(b)

End If

hasil.Text = hasil.Text + f

If LCase(chiper.Text) = chiper.Text Then

Text1.Text = LCase(Text1.Text)

Else

End If

Next i
End Sub

Private Sub Command2_Click()

On Error Resume Next

hasil.Text = ""

a = Len(chiper.Text)

c=1

For i = 1 To a

b = Asc(Mid(UCase(chiper.Text), i, 1))

If b > 64 And b < 123 Then

If c > Len(kunci.Text) Then

Do

c=c-1

Loop Until c = 1

Else

End If

d = Asc(Mid(UCase(kunci.Text), c, 1))

e = b + (d - 65)

If e > 90 Then

g = 65 + (e - 91)

Else

g=e

End If

f = Chr(g)

c=c+1

Else

f = Chr(b)
End If

hasil.Text = hasil.Text + f

If LCase(chiper.Text) = chiper.Text Then

hasil.Text = LCase(hasil.Text)

Else

End If

Next i

Call dekrip

End Sub

Private Sub Command3_Click()

hasil.Text = ""

kunci.Text = ""

chiper.Text = ""

End Sub

Private Sub Command4_Click()

End

End Sub
Textbox untuk PLAINTEXT namenya adalah txtplain

Textbox untuk KUNCI namenya adalah txtkunci

Textbox untuk CIPHER namenya adalah txtcipher

Tombol Enkrisi namenya adalah cmdEnkripsi

Adodc1 namenya adalah Adovigenere

Sedangkan untuk Source codenya adalah


Private Sub cmdEnkripsi_Click()
panjangplain = Len(Trim(txtplain.Text))
j=1
For I = 1 To panjangplain
kar = Mid(txtplain.Text, I, 1)
IndexAscii = Asc(kar) – 64
panjangkunci = Len(Trim(txtkunci.Text))
If kar = ” ” Then
data= ” “
j=j–1
Else
karkunci = Mid(txtkunci.Text, j, 1)
Adovigenere.RecordSource = “select * from tblvigenere where kunci = ‘” + karkunci +
“‘”
Adovigenere.Refresh
data = Adovigenere.Recordset.Fields(IndexAscii)
End If
If j = panjangkunci Then
j=1
Else
j=j+1
End If
sandi = sandi +data
Next I
txtcipher.Text = sandi
End Sub

Private Sub txtkunci_KeyPress(KeyAscii As Integer)


KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub txtplain_KeyPress(KeyAscii As Integer)


KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Sehingga jika dirun hasilnya seperti berikut :


1 # include <stdio.h>
02 # include <conio.h>
03 # include <string.h>
04  
05 int main(){
06    char keyword[100];
07    char msg[100];
08    int crypted;
09    int real_difference;
10    int i, k, l;

11  
12    printf("Masukkan keyword : ");
13    gets(keyword);
14  
15    printf("Masukkan message yang ingin di enkripsi : ");
16    gets(msg);

17  
18    k = strlen(keyword);
19    l = strlen(msg);
20  
21    while(k < l){
22     keyword = keyword + keyword;
23       k = strlen(keyword);
24    }

25  
26    printf("\n\n");
27    for ( i = 0; i <= strlen(msg); i++){
28     keyword[i] -= 'a' - 1;

29       if ( (msg[i] + keyword[i]) > 'z'){


30           crypted = 'a' + (keyword[i] + msg[i] - 'z') - 1;
31       }
32       else if(msg[i] == 32){
33           crypted = msg[i];
34       }

35       else {
36           crypted = msg[i] + keyword[i];
37       }
38  
39       printf("%c", crypted);
40       if ( i >= strlen(msg))break;
41     }
42     return 0;
43     getch();
44 }

You might also like