Kali ini saya akan
berbagi perogram Kriptograpi Caesar Cipher, Kriptografi Vernam Chiper, Kriftografi Gronsfeld dan Kriftografi Vigenere. Kriptograpi adalah ilmu dan
seni untuk menjaga keamanan pesan yang dikirim dari suatu tempat ketempat lain
. Karena formnya tidak hanya satu maka saya menggunakan menu utama agar mempermudah melihat
hasilnya. Langsung saja kita lihat gambarnya seperti di bawah ini.
- MENU UTAMA
Tambahkan MenuStrip
pada Form1
Buat MenuStrip yang ada
pada Form1 menjadi seperti dibawah ini.
Listing programnya: |
Public Class Form1
Private Sub KriptografiCaesarToolStripMenuItem_Click(ByVal sender As
System.Object, yVal e As
System.EventArgs) Handles
KriptografiCaesarToolStripMenuItem.Click
Form2.MdiParent = Me
Form2.Show()
End Sub
Private Sub EnkripsiKriptografiVernamToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
EnkripsiKriptografiVernamToolStripMenuItem.Click
Form3.MdiParent = Me
Form3.Show()
End Sub
Private Sub KriptografiGronsfeilToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KriptografiGronsfeilToolStripMenuItem.Click
Form4.MdiParent = Me
Form4.Show()
End Sub
Private Sub KriptoToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KriptoToolStripMenuItem.Click
Form5.MdiParent = Me
Form5.Show()
End Sub
Private Sub KeluarToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KeluarToolStripMenuItem.Click
End
End Sub
Private Sub KeluarToolStripMenuItem1_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KeluarToolStripMenuItem1.Click
End
End Sub
End Class
HASILNYA SEPERTI DIBAWAH INI:
- CAESAR CHIPER
DESAIN FOMNYA SEPERTI DIBAWWAH INI:
LISTING PROGRAMNYA:
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 As System.EventArgs) Handles btndeskripsi.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
plain.Text = xkalimat
End Sub
End Class
HASILNYA SEPERTI DIBAWAH INI:
- VERNAM CHIPER
LISTING PROGRAMNYA:
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
plainteks.Text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.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 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 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
End Class
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
plainteks.Text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.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 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 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
End Class
HASIL PROGRAMNYA:
- KRIPTOGRAFI GRONSFELD
Listing Programnya adalah:
Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.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
jum = Len(Text)
splain = ""
skey = kunci.Text
skata = 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))
nEnc = (nkata + nkunci) Mod 26
splain = splain & Chr((nEnc) + 65)
Next i
chiperteks.Text = splain
End Sub
End Class
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
jum = Len(Text)
splain = ""
skey = kunci.Text
skata = 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))
nEnc = (nkata + nkunci) Mod 26
splain = splain & Chr((nEnc) + 65)
Next i
chiperteks.Text = splain
End Sub
End Class
HASIL PROGRAMNYA ADALAH:
- KRIPTOGRAFI VIGENERE
Listing Programnya adalah:
Public Class Form5
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
plainteks.Text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.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
jum = Len(Text)
splain = ""
skey = kunci.Text
skata = 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))
nkunci = Asc(Mid(skey, j, 1))
nEnc = ((nkata + nkunci) Mod 256)
splain = splain & Chr((nEnc))
Next i
chiperteks.Text = splain
End Sub
End Class
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
plainteks.Text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.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
jum = Len(Text)
splain = ""
skey = kunci.Text
skata = 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))
nkunci = Asc(Mid(skey, j, 1))
nEnc = ((nkata + nkunci) Mod 256)
splain = splain & Chr((nEnc))
Next i
chiperteks.Text = splain
End Sub
End Class
DAN INILAH HASIL NYA:
DAN ITULAH HASIL ARI PROGRAM CAESAR CHIPER,VERNAM CHIPER, GRONSFELD, DAN VIGENERE.
WASSALAMUALAIKUM.........
Tidak ada komentar:
Posting Komentar