TUGAS PEMOGRAMAN KRIPTOGRAFI
1. Buka Microsoft
Visual Studio 2008
2. Klik => Create:
Project
3. Ubah Project name
dengan Nama anda atau dengan nama kriptografi
4. Maka setelah itu akan muncul sebuah Form1 pada Project kita
5.coba desain form seperti contoh gambar di bawah ini :
Untuk
membuat menu file gunakan menustrip yang ada pada toolbox ,lalu ketikan nama
kriptografi lalu ketikan tanda “ _” lalu enter gunanya untuk membuat garis
bawah pada nama kriptografi yang di buat tadi
Lalu
klik add windows form pada menu project
Lalu
desain form dengan ketentuan :
untuk “label”, anda hanya cukup mengganti “Text” nya saja,untuk “texsbox”
hanya cukup mengganti “Name” nya saja,untuk “button”nya baru di ganti “name”
dan “text”nya,bila sudah selesai di desain,maka langkah selanjutnyamenganti propertis text box pada kotak propertis
1.
multiline menjadi “ true”dan
2.
scroball menjadi “vertical”
Tampilan form menu kriptografi
Public Class Form1
Private Sub
KiptografivernamToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
KiptografiVernamToollStripMenuItem.Click
kriptografi_caesar.Show()pi
Me.Hide()
End Sub
Private Sub
KiptografiVernamToolStripMenuItem1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
KiptografiVernamToolStripMenuItem1.Click
kriptografi_Vernam.Show()
Me.Hide()
End Sub
Private Sub
KiptografivigenereToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
KiptografIVigenereToolStripMenuItem.Click
Kriptografi_Gronsfeld.Show()
Me.Hide()
End Sub
Private Sub
KiptografIVigenereToolStripMenuItem1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles KiptografIVigenereToolStripMenuItem1.Click
Kriptografi_Vigenere.Show()
Me.Hide()
End Sub
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
End Sub
End Class
Tampilan
form Kriptografi Caesar:
Listing
Program Kriptografi Caesar:
Public Class kriptografi_caesar
Private Sub
Btnenkripsi_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Btnenkripsi.Click
Dim x As String = ""
Dim xkalimat As String = ""
For i = 1 To
Len(Plain.Text)
x =
Mid(Plain.Text, i, i)
x =
Chr(Asc(x) + 3)
xkalimat =
xkalimat + x
Next
chiper.Text =
xkalimat
End Sub
Private Sub
Btndekripsi_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Btndekripsi.Click
Dim x As String = ""
Dim xkalimat As String = ""
For i = 1 To
Len(chiper.Text)
x =
Mid(chiper.Text, i, i)
x =
Chr(Asc(x) - 3)
xkalimat =
xkalimat + x
Next
plain.Text =
xkalimat
End Sub
Private Sub
chiper_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
chiper.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
chiper_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
chiper.TextChanged
End Sub
Private Sub
kriptografi_caesar_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
MyBase.Load
End Sub
End Class
Hasil
Program Kriptografi Caesar:
Enkripsi
dekripsi
Tampilan
form Kriptografi Vernam:
Listing Program Kriptografi Vernam :
Public Class kriptografi_Vernam
Private Sub
Label3_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Label3.Click
End Sub
Private Sub
kriptografi_Vernam_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
plainteks_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
plainteks.TextChanged
End Sub
End Class
Hasil
Program Kriptografi vernam:
Tampilan
form Kriptografi
Gronsfeld:
Listing
Program
Kriptografi Gronsfeld
Public Class Kriptografi_Gronsfeld
Private Sub
Kriptografi_Gronsfeld_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 =
(Mid(sKey, j, 1))
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
Hasil
Program Kriptografi Gronsfeld
Tampilan
form Kriptografi Vigenore
Listing
Program
Kriptografi Vigenore
Public Class Kriptografi_Vigenere
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 sPlainteks 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))
nKunci =
Asc(Mid(sKey, j, 1))
nEnc =
((nKata + nKunci) Mod 256)
sPlainteks
= sPlainteks & Chr((nEnc))
Next i
chiperteks.Text
= sPlainteks
Hasil program Kriptografi Vigenore