Monday 1 July 2013


Public Class Vernam


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        kunci.Text = ""
        chiperteks.Text = ""

    End Sub

    Private Sub enkript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkript.Click
        Dim a As Integer
        Dim jumlah 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 String
        a = 0
        sKata = plainteks.Text
        jumlah = Len(sKata)
        sKey = kunci.Text
        For i = 1 To jumlah
            If a = Len(sKey) Then
                a = 1
            Else
                a = a + 1

            End If
            nKata = Asc(Mid(sKata, i, 1)) - 65
            nKunci = Asc(Mid(sKey, a, 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 plainteks_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plainteks.TextChanged
    End Sub
End Class

Public Class Form1

    Private Sub Btnenskript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnenskript.Click
        Dim jumlah As Double = Len(plainteks.Text)
        Dim x As String
        Dim xkalimat As String = ""
        Dim i As Double
        Dim bil As Integer
        For i = 1 To jumlah
            x = Mid(plainteks.Text, i, 1)
            bil = Asc(x) + 3
            x = Chr(bil)
            xkalimat = xkalimat + x
        Next
        chipteks.Text = xkalimat
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        chipteks.Text = ""
    End Sub
End Class
Public Class vigenere

    Private Sub vigenere_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        kunci.Text = ""
        chiperteks.Text = ""
    End Sub

    Private Sub enkrippt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkrippt.Click
        Dim a As Integer
        Dim jumlah 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 String
        a = 0
        sKata = plainteks.Text
        jumlah = Len(sKata)
        sKey = kunci.Text
        For i = 1 To jumlah
            If a = Len(sKey) Then
                a = 1
            Else
                a = a + 1
            End If
            nKata = Asc(Mid(sKata, i, 1)) - 26
            nKunci = Asc(Mid(sKey, a, 1)) - 26
            nEnc = ((nKata + nKunci) Mod 26)
            sPlain = sPlain & Chr((nEnc) + 26)
        Next i
        chiperteks.Text = sPlain

    End Sub

    Private Sub chiperteks_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles chiperteks.KeyPress
        e.KeyChar = UCase(e.KeyChar)
        Dim tombol As Integer = Asc(e.KeyChar)
        If Not (((tombol >= 26) And (tombol <= 90) Or (tombol = 8))) 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 gronsfeld

    Private Sub gronsfeld_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        kunci.Text = ""
        chiperteks.Text = ""

    End Sub

    Private Sub plainteks_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plainteks.TextChanged
      
    End Sub

    Private Sub enkript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkript.Click
        Dim a As Integer
        Dim jumlah 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 String
        a = 0
        sKata = plainteks.Text
        jumlah = Len(sKata)
        sKey = kunci.Text
        For i = 1 To jumlah
            If a = Len(sKey) Then
                a = 1
            Else
                a = a + 1
            End If
            nKata = Asc(Mid(sKata, i, 1)) - 326
            nKunci = Asc(Mid(sKey, a, 1)) - 326
            nEnc = ((nKata + nKunci) Mod 326)
            sPlain = sPlain & Chr((nEnc) + 326)
        Next i
        chiperteks.Text = sPlain
    End Sub

    Private Sub chiperteks_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles chiperteks.KeyPress
        e.KeyChar = UCase(e.KeyChar)
        Dim tombol As Integer = Asc(e.KeyChar)
        If Not (((tombol >= 326) And (tombol <= 90) Or (tombol = 8))) 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


Silahkan Tinggalkan Komentar Anda :

0 comments:

Blog Archive

Popular Posts