Jumat, 05 Desember 2014

Pemograman Kriptografi dengan VB 2008

  •  Menu Utama

 Listing Program

Public Class Form1

    Private Sub KiptografiVernamToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KiptografiVernamToolStripMenuItem.Click
        Form2.Show()
    End Sub

    Private Sub KiptografiVernamToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KiptografiVernamToolStripMenuItem1.Click
        oneTimePad.Show()
    End Sub

    Private Sub KiptografiGronsfeldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KiptografiGronsfeldToolStripMenuItem.Click
        Form4.Show()

    End Sub


    Private Sub KiptografiVigenereToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KiptografiVigenereToolStripMenuItem.Click
        Form5.Show()
    End Sub

End Class

      Hasil Program

 

  •   Program Caesar Cipher 
    Design Form berikut ini:

     

    Listing Program

    Public Class Form2

        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(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


      
    • Vernam Chiper (One Time Pad)
    Design Form Sebagai brikut :

     

    Listing Program

    Public Class oneTimePad

        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 oneTimePad_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            plainteks.Text = ""
            kunci.Text = ""
            chiperteks.Text = ""
        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
    End Class

    Hasil Program


  • Kriptografi Gronsfeld
      
     Design Program Seperti Berikut Ini

Listing Program

 Public Class Form4

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


  Hasil Program

 

  • Kiptografi Viginere
Design Program Seperti berikut :
 

  Listing Program

Public Class Form5

    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

    End Sub
End Class

  





Ini adalah pemograman Kriptograpi Caesar Cipher,Vernam Chiper,Gronsfeld  dan Vigenere semoga bermanfaat :).

Tidak ada komentar:

Posting Komentar

Cara Menginstall Software Adobe Photoshop CS6

CARA MENGINSTALL SOFTWARE ADOBE PHOTOSHOP CS6 Haii guys, hari ini saya akan memberikan tutorial sederhana untuk menginstall Software...