PEMOGRAMAN
KRIPTOGRAFI
A.Vernam
Chiper(One Time Pad)
01.
Pertama Buka microsoft visual studio2008
02. Setelah itu klik Create: Project
03. Selanjutnya anda akan dibawa ke tampilan seperti di bawah
ini
Pada
kotak name : isikan nama project anda dengan sesuka hati.
Pada
kotak location : pilih tempat
penyimpanan project anda
Setelah
itu pilih OK
04. Maka akan muncul lembar kerja anda
05. Di lembar kerja anda isikan atau desain
seperti gambar di bawah ini:
Keterangan
Plainteks : label => textbox
Kunci : label => textbox
Chiperteks : label => textbox
Dikontak
properties ganti name texbok dan textnya,dan jangan lupa ganti juga “ multiline
= true” dan “scorollbars = vertical”
Enkripsi : button
Ganti
name button =btnenkripsi
Text
= enkripsi
06. Listing Program
Public Class OneTimePad
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 enkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles enkripsi.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 plainteks_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles plainteks.TextChanged
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
07. Setelah anda selesai menulis coding di atas
tekan F5 untuk menjalankanya,
Seperti di bawah ini
08. Selamat mencoba
Wassalam........