RSS

Kriptografi

Public Class Form1

    Private Sub KriptografiCaesarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiCaesarToolStripMenuItem.Click
        Form2.MdiParent = Me
        Form2.show()

    End Sub

    Private Sub KriptografiVernamToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVernamToolStripMenuItem.Click
        Form3.MdiParent = Me
        Form3.Show()

    End Sub

    Private Sub KriptografiGronsfeldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiGronsfeldToolStripMenuItem.Click
        Form4.MdiParent = Me
        Form4.Show()


    End Sub

    Private Sub KriptografiVigenereToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVigenereToolStripMenuItem.Click
        Form5.MdiParent = Me
        Form5.Show()


    End Sub

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

    End Sub

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

    End Sub
End Class


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Kemudian, bagian-bagian dari pada menu tersebut :

1. Kriptografi Caesar
    Tampilannya :
 
Listing Program :
Public Class Form2

    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, 1)
            x = Chr(Asc(x) + 3)
            xkalimat = xkalimat + x

        Next
        Chiper.Text = xkalimat

    End Sub

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

        Next
        Plain.Text = xkalimat

    End Sub
3. Kriptografi Vernam
    Tampilannya :




 

Listing Program :
Public Class Form3

    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)) - 61
            nKunci = Asc(Mid(sKey, j, 1)) - 86
            nEnc = ((nkata + nKunci) Mod 26)
            splain = splain & Chr((nEnc) + 61)

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

        End If

    End Sub

    Private Sub Plainteks_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Plainteks.TextChanged

    End Sub

    Private Sub Chiperteks_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chiperteks.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 >= 61) And (tombol <= 90)) Or (tombol = 80)) Then
            e.Handled = True
        End If
    End Sub





  



Kriptografi Gronsfeld
    Tampilannya :



 
Listing Program :

Public Class Form4
    Private Sub Gronsfeld_Chiper_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Input.Text = ""
        hasil.Text = ""
    End Sub

    Private Sub BtnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHitung.Click
        Dim ind As Integer
        Dim huruf, kalimat As String
        Dim jumlah(25) As Integer
        kalimat = (Input.Text).ToUpper
        For x = 1 To Microsoft.VisualBasic.Len(kalimat)
            huruf = kalimat.Substring(x - 1, 1)
            If (huruf >= "A") And (huruf <= "Z") Then
                ind = Asc(huruf) - 65
                jumlah(ind) += 1
            End If
        Next
        hasil.Text = ""
        For i As Integer = 0 To 25
            huruf = Chr(i + 65)
            If jumlah(i) > 0 Then
                hasil.Text = hasil.Text & huruf & " = " & jumlah(i) & vbCrLf
            End If
        Next
    End Sub

    Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
        Me.Close()
    End Sub
End Class

4. Kriptografi ViGenere
     Tampilannya :

Listing Program :
Public Class Form5

    Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
        ChiperTeks.Text = Enkripsi(PlainTeks.Text, Kunci.Text)

    End Sub
    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

End Class







  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar