Pemrograman Kriptografi ada 4 jenis yaitu :
1. Kriptografi Caesar Cipher
2. Kriptografi Vernam cipher
3. Kriptografi Gronsfeld
4. Kriptografi Vigenere
Nah pada postigan kali ini kita akan membahas ke empat Kriptografi tersebut dan kita akan mengetahui enkripsi dan dekripsi dan disini juga kita akan masukan ke empat jenis kriptografi tersebut ke dalam MenuStrip .
Sekarang kamu tambah kan form pada visual basic menjadi 5 form dan design lah seperti form-form d bawah ini .
Public Class Form1
Private Sub onetimepad_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
plainteks.Text = "Vivi aprianti"
Kunci.Text = "marpaung"
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 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
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
End Class
Public Class Form2
Private Sub KriptografiCaesarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiCaesarToolStripMenuItem.Click
Form1.MdiParent = Me
Form1.Show()
End Sub
Private Sub KriptografiVernamToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVernamToolStripMenuItem.Click
Form3.MdiParent = Me
Form3.Show()
End Sub
Private Sub KriptografiGransfildToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiGransfildToolStripMenuItem.Click
Form4.MdiParent = Me
Form4.Show()
End Sub
Private Sub KriptografiVigenereToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVigenereToolStripMenuItem.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
Close()
End Sub
End Class
Public Class Form3
Private Sub OneTimePad_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 nEnec 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
nEnec = ((nKata + nKunci) Mod 26)
sPlain = sPlain & Chr((nEnec) + 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_KeyPress1(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 btndekripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndekripsi.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 nEnec 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
nEnec = ((nKata - nKunci) Mod 26)
sPlain = sPlain & Chr((nEnec) + 65)
Next i
Chiperteks.Text = sPlain
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 = ""
Chiperteks.Text = ""
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 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 Btndekripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btndekripsi.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
End Class
Public Class Form4
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Plainteks.Text = ""
Chiperteks.Text = ""
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 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 Btndekripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btndekripsi.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
End Class
HASILANYA :
TERIMAKASIH, semoga dapat bermaanfaat...