Senin, 23 Desember 2013

Kriptografi



Menu utama
 
Listing program
Public Class menu

    Private Sub AplikasiKriptograpiCaesarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AplikasiKriptograpiCaesarToolStripMenuItem.Click
        Form1.Show()
    End Sub

    Private Sub EnkripsiKriptograpiVernamToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnkripsiKriptograpiVernamToolStripMenuItem.Click
        OneTimePad.Show()
    End Sub

  
    Private Sub GrosnfeilToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GrosnfeilToolStripMenuItem.Click
        Form3.Show()
    End Sub

    Private Sub KriptografiVigenereToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVigenereToolStripMenuItem.Click
        vigenere.Show()
    End Sub

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

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

    End Sub
End Class


Hasil program
 
KRIPTOGRAFI CAESAR
FORM DESAIGN
 
LISTING PROGRAM
Public Class CAESAR

  
    Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkripsi.Click
        Dim x As String = ""
        Dim kalimat As String = ""
        For i = 1 To Len(plain.Text)
            x = Mid(plain.Text, i, i)
            x = Chr(Asc(x) + 3)
            kalimat = kalimat + x
        Next
        chiper.Text = kalimat
    End Sub

    Private Sub dekripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dekripsi.Click
        Dim x As String = ""
        Dim kalimat As String = ""
        For i = 1 To Len(chiper.Text)
            x = Mid(chiper.Text, i, i)
            x = Chr(Asc(x) - 3)
            kalimat = kalimat + x
        Next
        plain.Text = kalimat
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        chiper.Text = ""
        plain.Text = ""
    End Sub

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

    End Sub
End Class


HASIL PROGRAM
 
KRIPTOGRAFI VERNAM
DESAIGN PROGRAM
 
LISTING PROGRAM
Public Class OneTimePad

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plain.Text = ""
        kunci.Text = ""
        chiper.Text = ""
    End Sub

    Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkripsi.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 = plain.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
        chiper.Text = splain


    End Sub

    Private Sub plain_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles plain.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 GRONFELD
DESAIGN PROGRAM
 
LISTING PROGRAM
Public Class Form3

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plain.Text = ""
        kunci.Text = ""
        chiper.Text = ""
    End Sub

    Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkripsi.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 = plain.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
        chiper.Text = splain

    End Sub

    Private Sub plain_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles plain.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 VIGENERE
DESAIGN PROGRAM
 
LISTING PROGRAM
Public Class 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 sPlain As String = ""
        Dim nEnc As Integer
        j = 0
        sKata = plain.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 26)
            sPlain = sPlain & Chr((nEnc))
        Next i
        chiper.Text = sPlain

    End Sub

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

    End Sub
End Class
HASIL PROGRAM