Cara membuat kroftografi dengan menggunakan Visual Basic 2008
Pertama
desainlah from seperti yang dibawa ini :
Untuk membuat listing program double click lember kerja yang
bebas icon_nya tau ikutin saja perintah di bawah seperti biasa_Nya:
Public Class Form1
Private Sub KeluarToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KeluarToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub KriptografiCaesarToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KriptografiCaesarToolStripMenuItem.Click
Form2.MdiParent = Me
Form2.Show()
End Sub
Private Sub KriftografiVernamToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KriftografiVernamToolStripMenuItem.Click
Form3.MdiParent = Me
Form3.Show()
End Sub
Private Sub MenuStrip1_ItemClicked(ByVal
sender As System.Object, ByVal e As
System.Windows.Forms.ToolStripItemClickedEventArgs) Handles
MenuStrip1.ItemClicked
End Sub
Private Sub KriftografifelGronsfeldToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KriftografifelGronsfeldToolStripMenuItem.Click
Form4.MdiParent = Me
Form4.Show()
End Sub
Public Class Form2
Private Sub btnEnkkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnEnkkripsi.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 btnDekripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnDekripsi.Click
Dim
jumlah As Double
= Len(plain.Text)
Dim x As String
Dim
xkalimat As String
= ""
Dim i As Double
Dim bil
As Integer
For i =
1 To jumlah
x = Mid(plain.Text, i, 1)
bil = Asc(x) + 3
x = Chr(bil)
xkalimat = xkalimat + x
Next i
chiper.Text = xkalimat End Sub
Public Class Form3
Private Sub orm3_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
plainteks.text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
Private Sub btnEnkkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnEnkkripsi.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 = plainteks.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
chiperteks.Text = splain
End Sub
Private Sub plainteks_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
plainteks.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 As
System.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
Private Sub kunci_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles kunci.TextChanged
End Sub
End Class
Public Class Form4
Private Sub Form4_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
plainteks.Text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
Private Sub btnEnkkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnEnkkripsi.Click
Dim j As Integer
Dim jum
As Integer
Dim
skey As Integer
Dim
nkata As Integer
Dim
nkunci As Integer
Dim
skata As String
Dim
splain As String
= ""
Dim
nEnc As Integer
j = 0
skata = plainteks.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 = Mid(skey, j, 1)
nEnc = ((nkata + nkunci) Mod 26)
splain = splain & Chr((nEnc) +
65)
Next i
chiperteks.Text = splain
End Sub
Private Sub plainteks_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
plainteks.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 As
System.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
Private Sub kunci_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles kunci.TextChanged
End Sub
End Class
Contoh dari Enkrifsi contoh dari Dekrifsi
Posting Komentar