Kamis, 27 Juni 2013

Program Vegenere Chiper Menggunkan VB.NET

Buat Design Seperti Digambar :

Lalu Ketikkan Programnya Seperti berikut:


Public Class Vegenere_Chiper

    Private Sub proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles proses.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

    Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
        plainteks.Text = ""
        chiperteks.Text = ""
        kunci.Text = ""
    End Sub
End Class

Dan Hasilnya :

0 komentar:

Posting Komentar

Template by:

Free Blog Templates