Desain menu awal program
Berikut ini adalah listing programnya :
Public Class Form1
Private Sub KeluarToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesKeluarToolStripMenuItem.Click
End
End Sub
Private Sub CaesarChToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesCaesarChToolStripMenuItem.Click
caesar_chiper.Show()
End Sub
Private Sub VernamChiperToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesVernamChiperToolStripMenuItem.Click
vernam_chiper.Show()
End Sub
Private Sub VigenereChiperToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesVigenereChiperToolStripMenuItem.Click
vigenere_chiper.Show()
End Sub
Private Sub DesChiperToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesDesChiperToolStripMenuItem.Click
des_chiper.Show()
End Sub
End Class
Berikut ini adalah listing programnya :
Public Class caesar_chiper
Private Sub caesar_chiper_Load(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
plaintext.Text = ""
chipertext.Text = ""
End Sub
Private Sub btnenkripsi_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnenkripsi.Click
Dim jumlah As Double = Len(plaintext.Text)
Dim x As String
Dim xkalimat As String = ""
Dim i As Double
Dim bil As Integer
For i = 1 To jumlah
x = Mid(plaintext.Text, i, 1)
bil = Asc(x) + 3
x = Chr(bil)
xkalimat = xkalimat + x
Next i
chipertext.Text = xkalimat
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnhapus.Click
plaintext.Text = ""
chipertext.Text = ""
End Sub
Private Sub btnkeluar_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs)
End
End Sub
Private Sub btnkeluar_Click_1(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnkeluar.Click
Me.Close()
End Sub
End Class
3.Kriptografi Vernam Cipher
Desain awal program :
Public Class vernam_chiper
Private Sub vernam_chiper_Load(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
End Sub
Private Sub btnenkripsi_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnenkripsi.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
chipertext.Text = sPlain
End Sub
Private Sub plaintext_KeyPress(ByVal sender As Object,ByVal e As System.Windows.Forms.KeyPressEventArgs) Handlesplaintext.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) Handleskunci.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 btnhapus_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnhapus.Click
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
End Sub
Private Sub btnkeluar_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnkeluar.Click
Me.Close()
End Sub
End Class
A4. Kriptografi Vigenere Cipher
Berikut ini syntaxnya :
Public Class vigenere_chiper
Private Sub btnenkripsi_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnenkripsi.Click
chipertext.Text = Enkripsi(plaintext.Text, kunci.Text)
End Sub
Function Enkripsi(ByVal Teks As String, ByVal Kunci AsString) As String
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(Teks)
sPlain = ""
sKey = Kunci
sKata = Teks
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
Enkripsi = sPlain
End Function
Private Sub btnhapus_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnhapus.Click
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
End Sub
Private Sub btnkeluar_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesbtnkeluar.Click
Me.Close()
End Sub
Private Sub vigenere_chiper_Load(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
End Sub
End Class
6. kritografi Des chiper
desain program :
berikut listing programnya :
Public Class Des_chiper
Private Sub Des_chiper_Load(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
plain.Text = ""
chip.Text = ""
End Sub
Private Sub deskripsi_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handlesdeskripsi.Click
Dim x As String = ""
Dim xkalimat As String = ""
For i = 1 To Len(chip.Text)
x = Mid(chip.Text, i, i)
x = Chr(Asc(x) - 3)
xkalimat = xkalimat + x
Next
plain.Text = xkalimat
End Sub
Private Sub hapus_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles hapus.Click
plain.Text = ""
chip.Text = ""
End Sub
Private Sub keluar_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles keluar.Click
Me.Close()
End Sub
End Class
Tidak ada komentar:
Posting Komentar