Welcome to My Blog

Selasa, 07 Januari 2014

BELAJAR BAHASA PEMROGRAMAN

BELAJAR BAHASA PEMROGRAMAN


Desain Form berikut ini…!!!

Komponen yang harus ditambah yaitu :
11. MenuStrip
22.ToolStrip
Cara desain :
  • Tarik/Drag MenuStrip ke Form. Pada kotak Type here ketikkan File trus Enter
1.Ketik Kriptografi Caesar
2.Ketik Kriptografi Vernam
3.Ketik Kriptografi Gonsfeld
4.Ketik Kriptografi Vigeneri
  • Tarik/Drag ToolStrip ke Form, then tambahkan Button sebanyak 5(lima)  kedalam toolbar dengan memilih menu Button yang ada pada ToolStripTrus, tambahkan menu File dan Keluar pada MenuStrip...!!!
    Pada Menu Filr, ketikkan Kriptografi Caesar, Kriptografi Vernam, Kriptogragi Gonsfeld, kriptografi Vigeneri, dan Keluar.

    Berikut Hasil desainya... :

    Pada kriptografi Caesar, ketikkan kode berikut :
    Kriptografi_Caesar.MdiParent = Me
            Kriptografi_Caesar.Show()Pada kriptografi Vernam, ketikkan kode berikut :
    Kriptografi_Vernam.MdiParent = Me
            Kriptografi_Vernam.Show()Pada kriptografi Gonsfeld, ketikkan kode berikut :
    Kriptografi_Gonsfeld.MdiParent = Me
            Kriptografi_Gonsfeld.Show()Pada kriptografi Vigeneri, ketikkan kode berikut :
    Kriptografi_Vigeneri.MdiParent = Me
            Kriptografi_Vigeneri.Show()

    Untuk bagian ToolStrip, berikut codingnya :
    Private Sub KeluarToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarToolStripMenuItem1.Click
            End
        End Sub

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

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

        Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
            KriptografiCaesarToolStripMenuItem.PerformClick()
        End Sub

        Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
            KriptografiVernamToolStripMenuItem.PerformClick()
        End Sub

        Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
            KriptografiGonsfeldToolStripMenuItem.PerformClick()
        End Sub

        Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
            KriptografiVigeneriToolStripMenuItem.PerformClick()
        End Sub
    End Class



    Desain Form berikut ini...!!!
    KRIPTOGRAFI CAESAR

    Berikut listing programnya…:
    Public Class Kriptografi_Caesar

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.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
    End Class


    Hasil program :
    Hasil Enkripsi


    Hasil Dekripsi



    KRIPTOGRAFI VERNAM
    Desain lah Form berikut ini…!!!
    Berikut listing programnya :
    Public Class Kriptografi_Vernam

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 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 Kriptografi_Vernam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Plainteks.Text = ""
            Kunci.Text = ""
            Chiperteks.Text = ""
        End Sub
    End Class


    Hasil Program :
     


    KRIPTOGRAFI GONSFELD
    Desain lah form berikut ini …!!!

    Berikut listing programnya…:
    Public Class Kriptografi_Gonsfeld

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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

        Private Sub Kunci_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Kunci.KeyPress
            Dim tombol As Integer = Asc(e.KeyChar)
            If Not (tombol >= 65) And (tombol = 1) Then
                e.Handled = True
            End If
        End Sub

        Private Sub Kriptografi_Gonsfeld_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Plainteks.Text = ""
            Kunci.Text = ""
            Chiperteks.Text = ""
        End Sub
    End Class

    Hasil program :




    KRIPTOGRAFI VIGENERI
    Desain lah form berikut ini…!!!


    Berikut listing programnya :
    Public Class Kriptografi_Vigeneri

       
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            chiper.Text = Enkripsi(plain.Text, kunci.Text)
        End Sub
        Function Enkripsi(ByVal Teks As String, ByVal Kunci As String) As String
            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
            jum = Len(Teks)
            sPlain = ""
            sKey = Kunci
            sKata = Teks
            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)
                sPlain = sPlain & Chr((nEnc))
            Next i
            Enkripsi = sPlain

        End Function

    End Class




    Hasil program :