KRIPTROGRAFI

http://www.mesran.blogspot.com/

Public Class Form1

    Private Sub Form1_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
        Form6.MdiParent = Me
        Form6.Show()
    End Sub

    Private Sub KRIPTROGRAFIVERNAMToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KRIPTROGRAFIVERNAMToolStripMenuItem.Click

        Form7.Show()

    End Sub

    Private Sub KRIPTROToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KRIPTROToolStripMenuItem.Click

        Form8.Show()
    End Sub

    Private Sub KRIPTOGRAFINIGERWAREToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KRIPTOGRAFINIGERWAREToolStripMenuItem.Click

        Form9.Show()
    End Sub

    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles username.TextChanged

    End Sub




    Private Sub BTNLOGIN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNLOGIN.Click
        If username.Text = "nama" And pass.Text = "123456" Then
            MessageBox.Show("SELAMAT DATANG")
            pass.Text = ""
            username.Text = ""
            Form6.ActiveForm.Hide()
            Dim form As New Form6
            Form6.Show()
        Else
            username.Text = ""
            pass.Text = ""
            MessageBox.Show(" Password yang Anda Masukkan SALAH ", " PERHATIAN !!!")
            username.Focus()
        End If
    End Sub

    Private Sub KELUARToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KELUARToolStripMenuItem.Click

    End Sub
End Class

Public Class Form6

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

    End Sub

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

    End Sub
End Class

Public Class Form7

Private Sub Form7_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
            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
        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 >= 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 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
End Class

Public Class Form8

    Private Sub Form8_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)) - 65

            nKunci = Asc(Mid(sKey, j, 1)) - 48

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

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

    Private Sub chiperteks_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles chiperteks.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then
            e.Handled = True

        End If
    End Sub

    Private Sub chiperteks_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chiperteks.TextChanged

    End Sub
End Class

Public Class Form9
    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 BTNPROSES_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNPROSES.Click
        chipertext.Text = Enkripsi(plaintext.Text, kunci.Text)
    End Sub

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

    End Sub
End Class










http://www.mesran.blogspot.com/

Komentar

Postingan populer dari blog ini

Menghapus data Pada Listview

PROGRAM PEMBAYARAN LISTRIK DENGAN VB NET

ENTAH SIAPA YANG TAHU??