Syntax nya:
PublicClass Form1
PrivateSub
KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
KeluarToolStripMenuItem.Click
End
EndSub
PrivateSub
CaesarChToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
CaesarChToolStripMenuItem.Click
caesar_chiper.Show()
EndSub
PrivateSub
VernamChiperToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
VernamChiperToolStripMenuItem.Click
vernam_chiper.Show()
EndSub
PrivateSub
VigenereChiperToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
VigenereChiperToolStripMenuItem.Click
vigenere_chiper.Show()
EndSub
PrivateSub
DesChiperToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
AutoKeyChiperToolStripMenuItem.Click
autokey_chiper.Show()
EndSub
PrivateSub
GronsfeldChiperToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
GronsfeldChiperToolStripMenuItem.Click
Des_chiper.Show()
EndSub
PrivateSub Form1_Load(ByVal sender As
System.Object, ByVal e As
System.EventArgs) HandlesMyBase.Load
EndSub
EndClass.
Tampilan Menu Autokey_chiper :
PublicClass autokey_chiper
PrivateSub autokey_chiper_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) HandlesMyBase.Load
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
EndSub
PrivateFunction AutokeyEncipher(ByVal
strPlaintext AsString, ByRef
strKey AsString) AsString
Dim i AsLong
Dim j AsLong
Dim c1 AsInteger
Dim strPlaintext2 AsString
Dim strKey2 AsString
Dim strCiphertext AsString
Dim strCiphertext2 AsString
Dim diffKeyLen AsInteger
Dim pAlphabet AsInteger
Dim cAlphabet AsInteger
Dim nShift AsInteger
'1. Hilangkan semua
karakter yang bukan alfabet dari strPlaintext
' dan simpan sebagai strPlaintext2
strPlaintext2 = ""
For i = 1 To strPlaintext.Length
c1 = Asc(Mid(strPlaintext, i, 1))
If (c1 >= 65 And c1 <=
90) Then
strPlaintext2 = strPlaintext2
& Chr(c1)
EndIf
Next i
'2. Hilangkan semua
karakter yang bukan alfabet dari strKey
' dan simpan sebagai
strKey2
strKey2 = ""
For i = 1 To strKey.Length
c1 = Asc(Mid(strKey, i, 1))
If (c1 >= 65 And c1 <=
90) Then
strKey2 = strKey2 & Chr(c1)
EndIf
Next i
'3. Susun kunci baru strKey2
berdasarkan kunci awal strKey kemudian
' ditambah plaintext
'perbedaan antara
panjang plaintext dan kunci
diffKeyLen = strPlaintext2.Length -
strKey2.Length
For i = 1 To diffKeyLen
'c1 =
Asc(Mid(strPlaintext2, i, 1))
strKey2 = strKey2 &
Mid(strPlaintext2, i, 1)
Next i
'4. Geser masing-masing
huruf pada plaintext
' dengan huruf yang
terkait pada key
strCiphertext = ""
For i = 1 To
strPlaintext2.Length
c1 = Asc(Mid$(strPlaintext2, i, 1))
nShift = Asc(Mid$(strKey2, i, 1)) -
65
If ((c1 >= 65) And (c1 <=
90)) Then
pAlphabet = c1 - 65 ' get the alphabet sequence
cAlphabet = (pAlphabet +
nShift) Mod 26 '
shifted alphabet
c1 = cAlphabet + 65 ' get character in 65 ... 90
EndIf
strCiphertext = strCiphertext &
Chr(c1)
Next i
'5. Susun strCiphertext
sesuai dengan urutan strPlaintext
strCiphertext2 = ""
strKey = ""
j = 1
For i = 1 To strPlaintext.Length
c1 = Asc(Mid$(strPlaintext, i, 1))
If ((c1 >= 65) And (c1 <=
90)) Then
strCiphertext2 = strCiphertext2
& Mid(strCiphertext, j, 1)
strKey = strKey &
Mid(strKey2, j, 1)
j = j + 1
Else
strCiphertext2 = strCiphertext2
& Chr(c1)
strKey = strKey &" "
EndIf
Next i
Return strCiphertext2
EndFunction
PrivateSub btnkeluar_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
btnkeluar.Click
Me.Close()
EndSub
PrivateSub btnhapus_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnhapus.Click
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
EndSub
PrivateSub btnenkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btn_Encipher.Click
chipertext.Text =
AutokeyEncipher(plaintext.Text, kunci.Text)
EndSub
PrivateSub plaintext_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles plaintext.TextChanged
EndSub
EndClass.
Tampilan
Menu Caesar_chiper :
Syntax nya:
PublicClass caesar_chiper
PublicClass caesar_chiper
PrivateSub caesar_chiper_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) HandlesMyBase.Load
plaintext.Text = ""
chipertext.Text = ""
EndSub
PrivateSub btnenkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnenkripsi.Click
Dim jumlah AsDouble =
Len(plaintext.Text)
Dim x AsString
Dim xkalimat AsString = ""
Dim i AsDouble
Dim bil AsInteger
For i = 1 To jumlah
x = Mid(plaintext.Text, i, 1)
bil = Asc(x) + 3
x = Chr(bil)
xkalimat = xkalimat + x
Next i
chipertext.Text = xkalimat
EndSub
PrivateSub btnhapus_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnhapus.Click
plaintext.Text = ""
chipertext.Text = ""
EndSub
PrivateSub btnkeluar_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
End
EndSub
PrivateSub btnkeluar_Click_1(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnkeluar.Click
Me.Close()
EndSub
EndClass
Tampilan
Menu Des_chiper :
Syntax nya :
PublicClass Des_chiper
PrivateSub Des_chiper_Load(ByVal sender
As System.Object, ByVal
e As System.EventArgs) HandlesMyBase.Load
plain.Text = ""
chip.Text = ""
EndSub
PrivateSub deskripsi_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
deskripsi.Click
Dim x AsString = ""
Dim xkalimat AsString = ""
For i = 1 To Len(chip.Text)
x = Mid(chip.Text, i, i)
x = Chr(Asc(x) - 3)
xkalimat = xkalimat + x
Next
plain.Text = xkalimat
EndSub
PrivateSub hapus_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
hapus.Click
plain.Text = ""
chip.Text = ""
EndSub
PrivateSub keluar_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
keluar.Click
Me.Close()
EndSub
EndClass.
Tampilan Menu Vernam_chiper :
Syntax
nya:
PublicClass vernam_chiper
PrivateSub vernam_chiper_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) HandlesMyBase.Load
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
EndSub
PrivateSub btnenkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnenkripsi.Click
Dim j AsInteger
Dim jum AsInteger
Dim sKey AsString
Dim nKata AsInteger
Dim nKunci AsInteger
Dim sKata AsString
Dim sPlain AsString = ""
Dim nEnc AsInteger
j = 0
sKata = plaintext.Text
jum = Len(sKata)
sKey = kunci.Text
For i = 1 To jum
If j = Len(sKey) Then
j = 1
Else
j = j + 1
EndIf
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
chipertext.Text = sPlain
EndSub
PrivateSub plaintext_KeyPress(ByVal
sender AsObject, ByVal
e As System.Windows.Forms.KeyPressEventArgs) Handles plaintext.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol AsInteger =
Asc(e.KeyChar)
IfNot (((tombol >= 65) And
(tombol <= 90)) Or (tombol = 8)) Then
e.Handled = True
EndIf
EndSub
PrivateSub kunci_KeyPress(ByVal sender AsObject, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles kunci.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol AsInteger =
Asc(e.KeyChar)
IfNot (((tombol >= 65) And
(tombol <= 90)) Or (tombol = 8)) Then
e.Handled = True
EndIf
EndSub
PrivateSub btnhapus_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnhapus.Click
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
EndSub
PrivateSub btnkeluar_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
btnkeluar.Click
Me.Close()
EndSub
PrivateSub kunci_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles kunci.TextChanged
EndSub
EndClass.
Tampilan
Menu Vigenere_chiper :
Syntax
nya :
PublicClass vigenere_chiper
PrivateSub btnenkripsi_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnenkripsi.Click
chipertext.Text =
Enkripsi(plaintext.Text, kunci.Text)
EndSub
Function Enkripsi(ByVal Teks AsString, ByVal Kunci
AsString) AsString
Dim j AsInteger
Dim jum AsInteger
Dim sKey AsString
Dim nKata AsInteger
Dim nKunci AsInteger
Dim sKata AsString
Dim sPlain AsString
Dim nEnc AsInteger
j = 0
jum = Len(Teks)
sPlain = ""
sKey = Kunci
sKata = Teks
For i = 1 To jum
If j = Len(sKey) Then
j = 1
Else
j = j + 1
EndIf
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
EndFunction
PrivateSub btnhapus_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnhapus.Click
plaintext.Text = ""
kunci.Text = ""
chipertext.Text = ""
EndSub
PrivateSub btnkeluar_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
btnkeluar.Click
Me.Close()
EndSub
PrivateSub vigenere_chiper_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) HandlesMyBase.Load
EndSub
Tidak ada komentar:
Posting Komentar