Kamis, 16 Januari 2014

CARA MEMBUAT PEMOGRAMAN KRIPTOGRAFI DENGAN VB 2008

CARA MEMBUAT PEMOGRAMAN KRIPTOGRAFI DENGAN VB 2008

OKE GUYS KALI INI SAYA AKAN MEMBERI TAHU BAGAIMANA CARA PEMBUATAN KRIPTOGRAFI DENGAN VB 2008. OKE LANGSUNG SAJA YA...
Berikut ini adalah desaign dan cara-cara penyelesaiannya
1. Tampilan dari menu utama
berikut desainnya:
Dan berikut ini adalah cara memanggil form-form yang akan di tampilkan dari menu utama:
Public Class Form1
   
    Private Sub PEMOGRAMANKRIPTOGRAFIToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PEMOGRAMANKRIPTOGRAFIToolStripMenuItem.Click
        Form2.MdiParent = Me
        Form2.Show()
    End Sub
    Private Sub PEMOGRAMANKRIPTOGRAFIToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PEMOGRAMANKRIPTOGRAFIToolStripMenuItem1.Click
        Form3.MdiParent = Me
        Form3.Show()
    End Sub
    Private Sub KRIPTOGRAFIToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KRIPTOGRAFIToolStripMenuItem.Click
        Form4.MdiParent = Me
        Form4.Show()
    End Sub
    Private Sub KRIPTOGRAFIVEGENERIToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KRIPTOGRAFIVEGENERIToolStripMenuItem.Click
        Form5.MdiParent = Me
        Form5.Show()
    End Sub
    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
End Class
Hasilnya:

2. Tampilan pemograman kriptografi caesar chiper
    berikut desaign nya:


Cara penyelesain nya:

Public Class Form2

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

    Private Sub deskripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deskripsi.Click
        Dim x As String = ""
        Dim xkalimat As String = ""
        For i = 1 To Len(plaintext.Text)
            x = Mid(plaintext.Text, i, i)
            x = Chr(Asc(x) + 3)
            xkalimat = xkalimat + x
        Next
        plaintext.Text = xkalimat
    End Sub

    Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        Dim lia As Integer
        lia = MsgBox("anda mau keluar ?", MsgBoxStyle.YesNo)
        If lia = MsgBoxResult.Yes Then
            Me.Close()
        End If
    End Sub

    Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
        plaintext.Text = ""
        chipertext.Text = ""
    End Sub

    Private Sub kkkriptogrfi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kkkriptogrfi.Click
        Me.Hide()
        kkkriptogrfi.Show()
    End Sub
End Class

Berikut hasil penggunaan enkripsi:


3. Cara penyelesaian  pemograman kriptografi vernam chiper:
    berikut desaign nya:


cara penyelesaian nya:

Public Class Form3

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Plaintext.Text = ""
        kunci.Text = ""
        chipertext.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 = Plaintext.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
        chipertext.Text = splain
    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 Plaintext_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Plaintext.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

hasilnya menggunakan enkripsi:


4. kriptografi gronfeld:
    berikut desain nya:


berikut penyelesaian nya:

Public Class Form4

    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plaintext.Text = ""

        chipertext.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
        jum = Len(Text)
        splain = ""
        skey = kunci.Text
        skata = 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))
            nEnc = (nkata + nkunci) Mod 26
            splain = splain & Chr((nEnc) + 65)


        Next i
        chipertext.Text = splain
    End Sub
End Class

berikut hasil nya:


5. CARA penggunaan kristografi vigenere
    Berikut desaign nya:


Berikut ini penyelesaian nya:

Public Class Form5

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plaintext.Text = ""
        kunci.Text = ""
        chipertext.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
        jum = Len(Text)
        splain = ""
        skey = kunci.Text
        skata = 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)
            splain = splain & Chr((nEnc))


        Next i
        chipertext.Text = splain
    End Sub
End Class

berikut hasil nya:



Demikian lah bagian dari kristografi dan cara penyelesaian nya.

Tidak ada komentar:

Posting Komentar