Sabtu, 18 Januari 2014

Program penggabungan Form login,Menu Utama,Kriptografi Caesar,Vernam,Gronsfeld,dan Viegere bagian 1

1. Form Login
Form desain:

Listing Program:
Public Class Form1

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        End
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        password.PasswordChar = "*"
    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles password.TextChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
        If user_name.Text = "Hendri" And password.Text = "123" Then
            MsgBox("selamat datang")
            Form2.Show()
            Me.Hide()
        Else
            MsgBox("maaf!pasword anda salah!")
            user_name.Text = ""
            password.Text = ""
            user_name.Focus()

        End If
    End Sub
End Class

Hasil tampilan:





2. Menu Utama:
Form desain:


Lisnting Program:
 Public Class Form2

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

    End Sub

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

    End Sub

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

    End Sub

    Private Sub KitrografiVigenereToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KitrografiVigenereToolStripMenuItem.Click
        Form6.MdiParent = Me
        Form6.Show()

    End Sub

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

    End Sub

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

    End Sub
End Class

Hasil Tampilan:


3. Kriptografi Caesar
Form desain:


Listing Program:
Public Class Form3

    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(plainteks.Text)
            x = Mid(plainteks.Text, i, i)
            x = Chr(Asc(x) + 3)
            xkalimat = xkalimat + x
        Next
        chiperteks.Text = xkalimat
    End Sub


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

    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(plainteks.Text)
            x = Mid(plainteks.Text, i, i)
            x = Chr(Asc(x) - 3)
            xkalimat = xkalimat + x
        Next
        chiperteks.Text = xkalimat
    End Sub

End Class

Hasil Tampilan Caesar Enkripsi:



Hasil Tampilan Caesar Dekripsi:



4. Kriptografi Vernam
Form desain:


Listing Program:
Public Class Form4


    Private Sub Kitrografi_Vernam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plain.Text = ""
        kunci.Text = ""
        chiper.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
        chiper.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 Tampilan:



5.Kriptografi Gronsfeld
Form desain:


Listing Program:
 Public Class Form5

    Private Sub Kriptografi_gronsfeld_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plain.Text = ""
        kunci.Text = ""
        chiper.Text = ""

    End Sub

    Private Sub plain_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles plain.KeyPress
        If ((e.KeyChar >= "0" And e.KeyChar <= "9") And e.KeyChar <> vbBack) Then e.Handled = True
    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
        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

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

            nEnc = ((nKata + nKunci) Mod 26)
            sPlain = sPlain & Chr((nEnc) + 65)
        Next i
        chiper.Text = sPlain
    End Sub

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

    End Sub
End Class

Hasil Tampilan:

Tidak ada komentar:

Posting Komentar