SELAMAT DATANG DI BLOG SAYA YANG JAUH DARI SEMPURNA

Saturday, January 18, 2014

KRIPTOGRAFI

 


Listing Program I


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


 Listing Program II



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



Listing Program III

 

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

selamat mencoba, bila ada kesalahan mohon bero komentar pada tempta yang telah disediakan,agara dapat segera diperbaiki

terima kasih http://mesran.blogspot.com/search?q=tugas+TI-M1213&x=0&y=0





No comments:

Post a Comment