TUGAS KRIPTOGRAFI CAESAR CHIPER, GRONSFIELD CHIPER, DLL


PERTAMA-TAMA BUAT DULU FORM MENU NYA:

TAMPILANNYA:Image

Listing programnya:

Public Class Form1

Private Sub KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarToolStripMenuItem.Click

End

End Sub

Private Sub CaesarChiperToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CaesarChiperToolStripMenuItem.Click

Form2.Show()

End Sub

Private Sub VernamChiperToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VernamChiperToolStripMenuItem.Click

Form3.Show()

End Sub

Private Sub GronsfieldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GronsfieldToolStripMenuItem.Click

Form4.Show()

End Sub

Private Sub RC4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RC4ToolStripMenuItem.Click

Form7.Show()

End Sub

Private Sub DesChiperToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DesChiperToolStripMenuItem.Click

Form6.Show()

End Sub

Private Sub VigenereChiperToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VigenereChiperToolStripMenuItem.Click

Form5.Show()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

End Class

Berikut isi daripada menu nya:

1. Caesar Chiper

Listing Program:

Public Class Form2

Private Sub Caesar_chiper_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Plaintext.Text = “”
Chipertext.Text = “”

End Sub

Private Sub btnenkript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkript.Click
Dim jumlah As Double = Len(Plaintext.Text)
Dim x As String
Dim xkalimat As String = “”
Dim bil As Integer
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
End Sub
End Class

Tampilannya:

Image

2. Gronsfield Chiper

Listing Program:

Public Class Form4

Private Sub Gronsfeld_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Plaintext.Text = “”
Chipertext.Text = “”

End Sub

Private Sub Btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkript.Click
Dim J As Integer
Dim Jum As Integer
Dim sKey As String
Dim nKata As Integer
Dim nKunci As String
Dim sKata As String
Dim sPlain As String = “”
Dim nEnc As Integer
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
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))
Next i
Chipertext.Text = sPlain
End Sub
Private Sub Plainteks_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Plaintext.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

Private Sub Kunci_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kunci.TextChanged

End Sub
End Class

Tampilannya:
Image

3.Vernam Chiper

Listing Program:

Public Class Form3

Private Sub Vernam_chiper_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Plaintext.Text = “”
Chipertext.Text = “”
kunci.Text = “”
End Sub
Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkript.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 = Plaintext.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
Chipertext.Text = sPlain

End Sub

Private Sub Plaintext_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Plaintext.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

Private Sub kunci_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kunci.TextChanged

End Sub
End Class

Tampilannya:
Image

4. Vigenere Chiper

Listing Program:

Public Class Form5

Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Plaintext.Text = “”
Chipertext.Text = “”

End Sub

Private Sub Btnenkript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkript.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 = Plaintext.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)) + 0
nKunci = Asc(Mid(sKey, J, 1)) + 0
nEnc = ((nKata + nKunci) Mod 256)
sPlain = sPlain & Chr((nEnc))
Next i
Chipertext.Text = sPlain

End Sub

Private Sub Plaintext_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Plaintext.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

Tampilannya:
Image

5. DES Chiper
Listing Program:

Public Class Form6
Private Sub btnenkript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkript.Click
Dim kunci As String, kunciChar As String, katabaru As String
Dim Pos As Integer
Dim i As Integer, Side1 As String, Side2 As String
Dim nEnc As Integer
Pos = 1
For i = 1 To Len(Plaintext.Text)
Plaintext.Text = Mid(Plaintext.Text, i, 1)
key.Text = Mid(key.Text, Pos, 1)
Chipertext.Text = Chipertext.Text & Chr(Asc(Of Char)() Xor Asc(key.Text))
If Pos = Len(kunci) Then Pos = 0
Pos = Pos + 1
Next i
If Len(Chipertext.Text) Mod 2 = 0 Then
Side1 = StrReverse(Left(Chipertext.Text, (Len(Chipertext.Text) / 2)))
Side2 = StrReverse(Right(Chipertext.Text, (Len(Chipertext.Text) / 2)))
Chipertext.Text = Side1 & Side2
End If
nEnc = Chipertext.Text
End Sub

Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class

Tampilannya:

Image

6.RC4

Listing Program:

Public Class Form7
Private Function Rc4(ByVal message As String, ByVal password As String) As String
Dim s = Enumerable.Range(0, 256).ToArray
Dim i, j As Integer
For i = 0 To s.Length – 1
j = (j + Asc(password(i Mod password.Length)) + s(i)) And 255
Dim temp = s(i)
s(i) = s(j)
s(j) = temp
Next
i = 0
j = 0
Dim sb As New System.Text.StringBuilder(message.Length)
For Each c As Char In message
i = (i + 1) And 255
j = (j + s(i)) And 255
Dim temp = s(i)
s(i) = s(j)
s(j) = temp
sb.Append(Chr(s((s(i) + s(j)) And 255) Xor Asc(c)))
Next
Return sb.ToString
End Function
Private Sub btnenkript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkript.Click
Chipertext.Text = Rc4(Plaintext.Text, Kunci.Text)
End Sub
End Class

Tampilannya:
Image

 

 

TUGAS BAHASA PEMROGRAMAN

Yuk! Belajar Pemrograman Visual Basic dot Net Di Mesran.Net


Selesaikanlah Kasus Berikut:
Buatlah program untuk menampilkan hasil ke listview untuk kasus Latihan Listview Perhitungan Penjualan Barang

Berikut Jawaban Program:

Design Form

yang 22

Listing Program:

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kode.Items.Add(“TS001”)
kode.Items.Add(“TS002”)
kode.Items.Add(“VG001”)
kode.Items.Add(“VG002”)
BuatTabel()
End Sub

Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(kode.Text, 2)
Select Case x
Case “TS” : merk.Text = “Toshiba”
Case “VG” : merk.Text = “V-Gen”
End Select
Dim y As String
y = Microsoft.VisualBasic.Right(kode.Text, 3)
Select Case y
Case “001” : nama.Text = “Flashdisk 4GB”
Case “002” : nama.Text = “Flashdisk 2GB”
End Select
If x = “TS” And y = “001” Then
harga.Text = “105000”
ElseIf x = “TS” And y = “002” Then
harga.Text = “75000”
ElseIf x = “VG” And y = “001” Then
harga.Text = “90000”
ElseIf x = “VG” And y = “002” Then
harga.Text = “60000”
End If

End Sub

Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
total.Text = Val(harga.Text) * Val(jumlah.Text)
End If
End Sub
Sub BuatTabel()
LV.Columns.Add(“No Pembelian”, 80, HorizontalAlignment.Center)
LV.Columns.Add(“Kode Barang”, 180, HorizontalAlignment.Left)
LV.Columns.Add(“Nama Barang”, 80, HorizontalAlignment.Center)
LV.Columns.Add(“Merk”, 80, HorizontalAlignment.Center)
LV.Columns.Add(“Harga”, 80, HorizontalAlignment.Center)
LV.Columns.Add(“Jumlah Beli”, 80, HorizontalAlignment.Center)
LV.Columns.Add(“Total Harga”, 80, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub

Sub IsiTabel()
Dim Lst As New ListViewItem
Lst.Text = no.Text
Lst.SubItems.Add(kode.Text)
Lst.SubItems.Add(nama.Text)
Lst.SubItems.Add(merk.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(jumlah.Text)
Lst.SubItems.Add(total.Text)
LV.Items.Add(Lst)
End Sub

Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
IsiTabel()
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
LV.Items.Clear()
End Sub

Private Sub btnhapusyang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusyang.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub

Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
End
End Sub

Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
no.Text = “”
nama.Text = “”
kode.Text = “”
merk.Text = “”
harga.Text = “”
total.Text = “”
jumlah.Text = “”
End Sub
End Class

yang 11

 

yang 33

Demikianlah Postingan Saya : Nama : Batara Silaban        NPM:1111551

Selamat Pemrograman VB NET