Rabu, 15 Januari 2014

Kriptografi

hii...dear
selamat siang hari ini saya akan berbagi membuat cara membuat tampilan aplikasi program kriptografi caesar..


CAESAR CHIPER
Caesar Chiper yaitu aplikasi yang digunakan untuk menyandikan kata sandi pada akun login. 





Public Class Form1


    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 Btndekrifsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btndekrifsi.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

oke.... selanjutnya saya akan berbagi tentang aplikasi kriptografi vernam, ditunggu yahhh...


kriptografi vernam


Ini nih artikel yang kedua tampilan aplikasi vernam ..
















Public Class form3

    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 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)
        e.KeyChar = UCase(e.KeyChar)
        Dim tombol As Integer = Asc(e.KeyChar)
        If Not (((tombol >= 65) And (tombol <= 90)) Or (tombol = 8)) Then

        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



KRIPTOGRAFI GRONSFELD


Apllikasi ini hampir sama denganKriptografi Vernam hanya bedanya pada kata kunci,, Aplikasi Kriptografi Gronsfeld kata kuncinya menggunakan angka sedangkan Kriptografi Vernam menggunakan huruf,,






Public Class form4

    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 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)) - 48

            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
        If ((e.KeyChar >= "0" And e.KeyChar <= "9") And e.KeyChar <> vbBack) Then e.Handled = True
    End Sub

    Private Sub kunci_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles kunci.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True
    End Sub



End Class



oke,, selanjutnnya....


KRIPTOGRAFI VIGENERE

Public Class Form5

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        chiperteks.Text = ""
        kunci.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)) + 0
            nKunci = Asc(Mid(sKey, J, 1)) + 0
            nEnc = ((nKata + nKunci) Mod 256)
            sPlain = sPlain & Chr((nEnc))
        Next i
        chiperteks.Text = sPlain
    End Sub

End Class







Demikian lah aplikasi kriptografi caesar,vernam,gronsfeld,dan vigenere..
oleh nita psd..