1.Vernam.
Public Class Form1
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
plain.Text = ""
chiper.Text = ""
End Sub
Private Sub btnenkrip_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnenkrip.Click
Dim
jumlah As Double
= Len(plain.Text)
Dim x As String
Dim
xkalimat As String
= ""
Dim i As Double
Dim bil
As Integer
For i =
1 To jumlah
x = Mid(plain.Text, i, 1)
bil = Asc(x) + 3
x = Chr(bil)
xkalimat = xkalimat + x
Next i
chiper.Text = xkalimat
End Sub
Private Sub btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnhapus.Click
plain.Text = ""
chiper.Text = ""
End Sub
Private Sub btnkeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnkeluar.Click
Close()
End Sub
End Class
Public Class chiperteks_caesar
Private Sub btnenkrip_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnenkrip.Click
Dim x As String
Dim bil
As Integer
chiper.Text = ""
For i =
1 To Len(plain.Text)
x =
Microsoft.VisualBasic.Mid(plain.Text, i, 1)
bil = Asc(x)
bil = bil + 3 Mod 26
x = Chr(bil)
chiper.Text = chiper.Text & x
Next
End Sub
Private Sub chiperteks_caesar_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
chiper.Text = ""
plain.Text = ""
End Sub
Private Sub btndes_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btndes.Click
Dim x As String
Dim bil
As Integer
chiper.Text = ""
For i =
1 To Len(plain.Text)
x =
Microsoft.VisualBasic.Mid(plain.Text, i, 1)
bil = Asc(x)
bil = bil - 3 Mod 26
x = Chr(bil)
chiper.Text = chiper.Text & x
Next
End Sub
Private Sub btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnhapus.Click
chiper.Text = ""
plain.Text = ""
End Sub
End Class
4.Gronsfeld
3. Vigenere
Public Class vigenere
Private Sub btnProses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnProses.Click
chiper.Text = Enkripsi(plain.Text,
kunci.Text)
End Sub
Function
enkripsi(ByVal teks As
String, ByVal
kunci As String)
As String
Dim a As Integer
Dim b 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
a = 0
b = Len(teks)
sPlain = ""
sKey = kunci
sKata = teks
For i =
1 To b
If
a = Len(sKey) Then
a = 1
Else
a = a + 1
End
If
nKata = Asc(Mid(sKata, i, 1))
nKunci = Asc(Mid(sKey, a, 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
plain.Text = ""
chiper.Text = ""
kunci.Text = ""
End Sub
Private Sub btnkeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnkeluar.Click
Close()
End Sub
End Class
4.Gronsfeld
Public Class gronsfeld
Private Sub btnEn_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnEn.Click
Dim x As String
Dim CI As Integer
chiper.Text = ""
For i =
1 To Len(plain.Text)
x =
Microsoft.VisualBasic.Mid(plain.Text, i, 1)
CI = Asc(x)
CI = (plain.Text + kunci.Text) Mod 26
x = Chr(CI)
chiper.Text = chiper.Text & x
Next
chiper.Text = enkripsi(plain.Text,
kunci.Text)
End Sub
Private Sub btnDes_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnDes.Click
Dim x As String
Dim CI As Integer
Dim KI As Integer
Dim PI As Integer
chiper.Text = ""
For i =
1 To Len(plain.Text)
x =
Microsoft.VisualBasic.Mid(plain.Text, i, 1)
PI = Asc(x)
PI = (CI - KI) Mod 26
x = Chr(PI)
chiper.Text = chiper.Text & x
Next
End Sub
Function
enkripsi(ByVal teks As
String, ByVal
kunci As String)
As String
Dim a As Integer
Dim b 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
a = 0
b = Len(teks)
sPlain = ""
sKey = kunci
sKata = teks
For i =
1 To b
If
a = Len(sKey) Then
a = 1
Else
a = a + 1
End
If
nKata = Asc(Mid(sKata, i, 1))
nKunci = Asc(Mid(sKey, a, 1))
nEnc = ((nKata + nKunci) Mod 26)
sPlain = sPlain & Chr((nEnc))
Next i
enkripsi = sPlain
End Function
Private Sub gronsfeld_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
chiper.Text = ""
plain.Text = ""
kunci.Text = ""
End Sub
Private Sub btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnhapus.Click
chiper.Text = ""
plain.Text = ""
kunci.Text = ""
End Sub
End Class
0 komentar:
Posting Komentar