Kriptografi Caesar, Vernam, Groundsfield, dan Vegenere

Minggu, 19 Januari 20140 komentar

   A.    Kriptografi Caesar
ketik listing berikut ini :

Add caption
Public Class Kriptografi_Caesar
    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(plaint.Text)
            x = Mid(plaint.Text, i, i)
            x = Chr(Asc(x) + 3)
            xkalimat = xkalimat + x
        Next
        chiper.Text = xkalimat
    End Sub
    Private Sub btndeskripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndeskripsi.Click
        Dim a As String = ""
        Dim akalimat As String = ""
        For i = 1 To Len(plaint.Text)
            a = Mid(plaint.Text, i, i)
            a = Chr(Asc(a) - 3)
            akalimat = akalimat + a
        Next
        chiper.Text = akalimat
    End Sub
End Class
   B.      Kriptografi Vernam
ketik listing berikut ini:
Public Class Kriptografi_vernam
    Private Sub Kriptografi_Karna_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        DDD.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 splaint As String = ""
        Dim nenc As Integer
        j = 0
        skata = plainteks.Text
        jum = Len(skata)
        skey = DDD.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, i, 1)) - 65
            nenc = ((nkata + nkunci) Mod 26)
            splaint = splaint & Chr((nenc) + 65)
        Next i
        chiperteks.Text = splaint
    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 DDD.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 btn_deskripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_deskripsi.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 splaint As String = ""
        Dim nenc As Integer
        j = 0
        skata = plainteks.Text
        jum = Len(skata)
        skey = DDD.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, i, 1)) - 65
            nenc = ((nkata + nkunci) Mod 26)
            splaint = splaint & Chr((nenc) + 65)
        Next i
        chiperteks.Text = splaint
    End Sub
End Class
   C.      Kriptografi Groundsfield
 ketik listing berikut ini :
 Public Class Kriptografi_Gronsfield
    Private Sub Kriptografi_Karna_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        DDD.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 splaint As String = ""
        Dim nenc As Integer
        j = 0
        skata = plainteks.Text
        jum = Len(skata)
        skey = DDD.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)
            splaint = splaint & Chr((nenc) + 65)
        Next i
        chiperteks.Text = splaint
    End Sub
    Private Sub btn_deskripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_deskripsi.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 splaint As String = ""
        Dim nenc As Integer
        j = 0
        skata = plainteks.Text
        jum = Len(skata)
        skey = DDD.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, i, 1)) - 48
            nenc = ((nkata + nkunci) Mod 26)
            splaint = splaint & Chr(nenc - 65)
        Next i
        chiperteks.Text = splaint
    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 DDD.KeyPress
        e.KeyChar = UCase(e.KeyChar)
        Dim tombol As Integer = Asc(e.KeyChar)
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then
            e.Handled = True
        End If
    End Sub
End Class
   D.      Kriptografi Vegenere
Ketik listing program dibawah ini :

Public Class Kriptografi_Vigenere
    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
    Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.Click
        chipertext.Text = Enkripsi(plaintext.Text, kunci.Text)
    End Sub
End Class
Inilah merupakan jenis-jenis kriptografi yang dapat anda lihat dan pelajari. Semoga anda dapat terbantu dan semoga informasi ini dapat bermanfaat untuk semua pembaca artikel ini...
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. A & L FOREVER - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger