Membuat Program Kriptografi Caesar, Vernam, Gronsfeld dan Vigenere
Langsung aja pada materi yang mau di kerjakan, Buka VB 2008, create project
Design form 1, form 2, form 3, form 4, form 5
Pada Form1 buat Menu untuk Kriptografinya.
Pilih Menustrip pada toolbox
Seperti ini designya
coddingnya seperti berikut,
Public Class Form1
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 KriptografiVernamToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles KriptografiVernamToolStripMenuItem.Click
Form3.MdiParent = Me
Form3.Show()
End Sub
Private Sub KriptografiGronsfeldToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
KriptografiGronsfelToolStripMenuItem.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
Dim tanya As String
tanya = MsgBox("Anda Yakin Ingin Keluar ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If tanya = vbYes Then
tanya = MsgBox("Anda Yakin Ingin Keluar ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If tanya = vbYes Then
Me.Close()
End Sub
End Class
untuk membuat kriptografi caesarnya, seperti yg telah di bahas di blog saya sebelumnya Program Kriptografi Visual Basic 2008
design kriptografi caesar |
codding caesar :
Public Class
Form1
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, 1)
x = Chr(Asc(x) + 3)
xkalimat = xkalimat + x
Next
plain.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(chiper.Text)
x = Mid(chiper.Text, i, 1)
x = Chr(Asc(x) - 3)
xkalimat = xkalimat + x
Next
chiper.Text = xkalimat
End Sub
Private Sub
btnexit_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnexit.Click
Dim tanya As String
tanya = MsgBox("Anda Yakin Ingin Keluar
?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If tanya = vbYes Then
Me.Close()
Else
Exit Sub
End If
End Sub
End Class
Design Kriptografi Vernam |
Setelah ini, Buat codding pada Kriptografi Vernam :
Public Class Form3
Private Sub Form3_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
plain.Text = ""
chiper.Text = ""
kunci.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 = plain.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
chiper.Text = splain
End Sub
Private Sub plain_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
plain.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim
tombol As Integer
= Asc(e.KeyChar)
If Not (((tombol >= 61) 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 >= 61) And
(tombol <= 90)) Or (tombol = 80)) Then
e.Handled = True
End If
End Sub
End Class
Kriptografi Gronsfeld
Buat designnya dulu yah...
Design Kriptografi Gronsfeld |
Masukkan coddingnya
Public Class Form4
Private Sub Form4_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
input.Text = ""
process.Text = ""
End Sub
Private Sub btncount_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btncount.Click
Dim ind
As Integer
Dim huruf, kalimat As
String
Dim
jumlah(25) As Integer
kalimat = (input.Text).ToUpper
For x =
1 To Microsoft.VisualBasic.Len(kalimat)
huruf = kalimat.Substring(x - 1, 1)
If
(huruf >= "A") And (huruf <= "Z")
Then
ind = Asc(huruf) - 65
jumlah(ind) += 1
End
If
Next
process.Text = ""
For i As Integer = 0 To 25
huruf = Chr(i + 65)
If
jumlah(i) > 0 Then
process.Text = process.Text
& huruf & " = " &
jumlah(i) & vbCrLf
End
If
Next
End Sub
Private Sub btnexit_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnexit.Click
Dim
tanya As String
tanya = MsgBox("Yakin
Ingin di Tutup??", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If
tanya = vbYes Then
Me.Close()
End If
End Sub
End Class
Terkahir nih,,
Kriptografi Vigenere
buat designya dulu,,,,
Design Kriptografi Vigenere |
Masukkan coddingnya
Public Class Form5
Private Sub btnprocess_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnprocess.Click
chiperteks.Text =
Enkripsi(plainteks.Text, kunci.Text)
End Sub
Function
Enkripsi(ByVal Teks As
String, ByVal
Kunci As String)
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)
sKey = Kunci
sKata = plainteks.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
Enkripsi = sPlain
End Function
Private Sub btnreset_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnreset.Click
plainteks.Text = ""
chiperteks.Text = ""
kunci.Text = ""
End Sub
End Class
Public Class Form1
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, 1)
x = Chr(Asc(x) + 3)
xkalimat = xkalimat + x
Next
plain.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(chiper.Text)
x = Mid(chiper.Text, i, 1)
x = Chr(Asc(x) - 3)
xkalimat = xkalimat + x
Next
chiper.Text = xkalimat
End Sub
Private Sub btnexit_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnexit.Click
Dim
tanya As String
tanya = MsgBox("Anda
Yakin Ingin Keluar ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If
tanya = vbYes Then
Me.Close()
Else
Exit
Sub
End If
End Sub
End Class
- See more at: http://trisuhairy94.blogspot.com/2013/12/program-kriptografi-visual-basic-2008.html#sthash.0Eu5MXtZ.dpuf
Public Class Form1
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, 1)
x = Chr(Asc(x) + 3)
xkalimat = xkalimat + x
Next
plain.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(chiper.Text)
x = Mid(chiper.Text, i, 1)
x = Chr(Asc(x) - 3)
xkalimat = xkalimat + x
Next
chiper.Text = xkalimat
End Sub
Private Sub btnexit_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnexit.Click
Dim
tanya As String
tanya = MsgBox("Anda
Yakin Ingin Keluar ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If
tanya = vbYes Then
Me.Close()
Else
Exit
Sub
End If
End Sub
End Class
- See more at: http://trisuhairy94.blogspot.com/2013/12/program-kriptografi-visual-basic-2008.html#sthash.0Eu5MXtZ.dpuf
Public Class Form1
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, 1)
x = Chr(Asc(x) + 3)
xkalimat = xkalimat + x
Next
plain.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(chiper.Text)
x = Mid(chiper.Text, i, 1)
x = Chr(Asc(x) - 3)
xkalimat = xkalimat + x
Next
chiper.Text = xkalimat
End Sub
Private Sub btnexit_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnexit.Click
Dim
tanya As String
tanya = MsgBox("Anda
Yakin Ingin Keluar ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If
tanya = vbYes Then
Me.Close()
Else
Exit
Sub
End If
End Sub
End Class
- See more at: http://trisuhairy94.blogspot.com/2013/12/program-kriptografi-visual-basic-2008.html#sthash.0Eu5MXtZ.dpuf
Terima Kasih Telah Mengunjungi Blog saya dan Berkomentar dengan Sopan :)