Program Enkripsi Vernam (One Time Pad) Menggunakan VB Net
Written By Mesran on Kamis, 13 Juni 2013 | 09.09
Sebelumnya saya sudah membahas mengenai Kriptografi Vernam Chiper (One Time Pad), dan pada artikel ini saya akan memberikan program pembelajaran dari pemakaian kriptografi vernam tersebut.Pada program saya mendesain hanya karakter saja yang bisa di terima.
Design dahulu form program enkripsi vernam (one time pad) menggunakan vb net, berikut ini
Berikut listing program enkripsi vernam (one time pad) menggunakan vb net
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 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
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
End Class
Silahkan anda tekan F5, dan isikan data berikut :
Plainteks : SAYANGAKUCINTAKAMU
Kunci : ALDYAN
Chiperteks: SLBYNTAVXAIATLNYMH
Hasil form program enkripsi vernam (one time pad) menggunakan vb net