Langsung za Yach.....!!!!!
pertama kita harus buat 5 form.
Dimana form1 sabagai form utama dan form2 sampai form5 merupakan form kriptografinya.
1. Pada form1 buatlah tampilan seperti ini

Buatlah kodenya Sebagai berikut
Public Class Form1
Private Sub CaesarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CaesarToolStripMenuItem.Click
Form2.Show()
End Sub
Private Sub ViernamToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViernamToolStripMenuItem.Click
Form3.Show()
End Sub
Private Sub GronsfeldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GronsfeldToolStripMenuItem.Click
form4.Show()
End Sub
Private Sub VigenoreToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VigenoreToolStripMenuItem.Click
form5.Show()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Lalu pada Form 2, Buatlah seperti di bawah ini tampilannya :
Lalu klik double form 2, masukkan kode berikut ini :
Public Class Form2
Private Sub Btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Btnenkripsi.Click
Dim x As String = ""
Dim xkalimat As String = ""
For i = 1 To Len(plain.Text)
x = Mid(plain.Text, i, i)
x = Chr(Asc(x) + 3)
xkalimat = xkalimat + x
Next
chiper.Text = xkalimat
End Sub
Private Sub Btndeskripsi_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Btndeskripsi.Click
Dim x As String = ""
Dim xenkripsi As String = ""
For i = 1 To Len(chiper.Text)
x = Mid(chiper.Text, i, i)
x = Chr(Asc(x) - 3)
xenkripsi = xenkripsi + x
Next
chiper.Text = xenkripsi
End Sub
End Class
Lalu pada Form3, buatlah seperti gambar dibawah ini :
Kemudian klik double form 3 tersebut dan masukkan code berikut ini :
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load
plaintext.Text = ""
kunci.Text = ""
chippertext.Text = ""
End Sub
Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles enkripsi.Click
Dim J As Integer
Dim jum As Integer
Dim skey As String
Dim nkata As Integer
Dim nkunci As Integer
Dim skata As String
Dim splain As String = ""
Dim nenc As Integer
J = 0
skata = plaintext.Text
jum = Len(skata)
skey = kunci.Text
For i = 1 To jum
If J = Len(skey) Then
J = 1
Else
J = J + 1
End If
nkata = Asc(Mid(skata, i, 1)) - 65
nkunci = Asc(Mid(skey, J, 1)) - 65
nenc = ((nkata + nkunci) Mod 26)
splain = splain & Chr((nenc) + 65)
Next i
chippertext.Text = splain
End Sub
Private Sub plaintext_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles plaintext.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol As Integer = Asc(e.KeyChar)
If Not (((tombol >= 65) And (tombol <= 90)) Or (tombol = 8)) Then
e.Handled = True
End If
End Sub
Private Sub kunci_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles kunci.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol As Integer = Asc(e.KeyChar)
If Not (((tombol >= 65) And (tombol <= 90)) Or (tombol = 8)) Then
e.Handled = True
End If
End Sub
End Class
Pada Form4 buatlah sepeti ini :
Lalu buatlah code berikut ini :
Public Class Form4
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load
plaintext.Text = ""
kunci.Text = ""
chippertext.Text = ""
End Sub
Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles enkripsi.Click
Dim J As Integer
Dim jum As Integer
Dim skey As String
Dim nkata As Integer
Dim nkunci As Integer
Dim skata As String
Dim splain As String = ""
Dim nenc As Integer
J = 0
skata = plaintext.Text
jum = Len(skata)
skey = kunci.Text
For i = 1 To jum
If J = Len(skey) Then
J = 1
Else
J = J + 1
End If
nkata = Asc(Mid(skata, i, 1)) - 26
nkunci = Asc(Mid(skey, J, 1)) - 10
nenc = ((nkata + nkunci) Mod 26)
splain = splain & Chr((nenc) + 65)
Next i
chippertext.Text = splain
End Sub
Private Sub plaintext_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles plaintext.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol As Integer = Asc(e.KeyChar)
If Not (((tombol >= 65) And (tombol <= 90)) Or (tombol = 8)) Then
e.Handled = True
End If
End Sub
Private Sub kunci_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles kunci.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol As Integer = Asc(e.KeyChar)
If Not (((tombol >= 48) And (tombol <= 57)) Or (tombol = 8)) Then
e.Handled = True
End If
End Sub
End Class
Pada Fom5 bentuklah tampilannya seperti di bawah ini :
Lalu pastekan code di bawah ini pada form5 :
Public Class Form5
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load
plaintext.Text = ""
kunci.Text = ""
chippertext.Text = ""
End Sub
Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles enkripsi.Click
Dim J As Integer
Dim jum As Integer
Dim skey As String
Dim nkata As Integer
Dim nkunci As Integer
Dim skata As String
Dim splain As String = ""
Dim nenc As Integer
J = 0
skata = plaintext.Text
jum = Len(skata)
skey = kunci.Text
For i = 1 To jum
If J = Len(skey) Then
J = 1
Else
J = J + 1
End If
nkata = Asc(Mid(skata, i, 1)) - 65
nkunci = Asc(Mid(skey, J, 1)) - 65
nenc = ((nkata + nkunci) Mod 26)
splain = splain & Chr((nenc) + 65)
Next i
chippertext.Text = splain
End Sub
Private Sub plaintext_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles plaintext.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol As Integer = Asc(e.KeyChar)
If Not (((tombol >= 65) And (tombol <= 90)) Or (tombol = 8)) Then
e.Handled = True
End If
End Sub
Private Sub kunci_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles kunci.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol As Integer = Asc(e.KeyChar)
If Not (((tombol >= 32) And (tombol <= 47)) Or (tombol = 8)) Then
e.Handled = True
End If
End Sub
End Class
Sekian dulu ya postingan saya. semoga postingan ini dapat bermanfaat.
Tidak ada komentar:
Posting Komentar