Program untuk menampilkan hasil Enkripsi berikut ini caranya
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 nErc As Integer
j = 0
sKata = Plainteks.Text
jum = Len(sKata)
skey = Kunci.Text
For i = 1 To jum
If j = Len(skey) Then
Else
j = j + 1
End If
nKata = Asc(Mid(sKata, i, 1)) - 65
nKunci = Asc(Mid(skey, j, 1)) - 65
nErc = ((nKata + nKunci) Mod 26)
sPlain = sPlain & Chr((nErc) + 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

