Sabtu, 18 Januari 2014

Pemograman Kriptografi dalam M. Visual Basic 2008

membuat MenuStrip nya

Public Class Form2

    Private Sub Form1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Form3.MdiParent = Me
        Form3.Show()

    End Sub

    Private Sub KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub Form2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Form1.MdiParent = Me
        Form1.Show()

    End Sub

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

    End Sub

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

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

    End Sub

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

    Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem.Click
        MsgBox("Awassss... Ini Milik Pribadi")
    End Sub

    Private Sub KeluarToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarToolStripMenuItem.Click
        End
    End Sub
End Class

hasil outputnya :





Program Kriptografi Caesar
Public Class Form3

    Private Sub Plain_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Plain.TextChanged

    End Sub

    Private Sub Enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enkripsi.Click
        Dim x As String = ""
        Dim xenkripsi As String = ""
        For i = 1 To Len(Chipper.Text)
            x = Mid(Chipper.Text, i, i)
            x = Chr(Asc(x) - 3)
            xenkripsi = xenkripsi + x
        Next
        Chipper.Text = xenkripsi
    End Sub

    Private Sub Dekripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dekripsi.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
        Chipper.Text = xkalimat
    End Sub

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

    End Sub
End Class

hasil outputnya :




Kriptografi Veernan
Public Class Form4

    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Plain.Text = ""
        Kunci.Text = ""
        Chipper.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
        Chipper.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 Plain_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Plain.TextChanged

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

    End Sub
End Class

hasil outputnya:




Kriptografi Gronfeld

Public Class Form5

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PlainText.Text = ""
        Kunci.Text = ""
        ChipperText.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)) - 26
            nkunci = Asc(Mid(skey, J, 1)) - 10
            nenc = ((nkata + nkunci) Mod 26)
            splain = splain & Chr((nenc) + 65)
        Next i
        ChipperText.Text = splain

    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

    Private Sub PlainText_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlainText.TextChanged

    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

    Private Sub Kunci_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kunci.TextChanged

    End Sub
End Class

Hasil outputnya :
 
 

Tidak ada komentar:

Posting Komentar