Sunday 30 June 2013

Tugas Postinggan

http://mesran.blogspot.com/2013/05/tugas-ti-p1104.html

A. Program Caesar_Chiper

 1.click Menu file pilih Caesar Chiper


 2. Maka akan tampil Program Caesar Chiper



LISTING PROGRAM CAESAR_CHIPER
Public Class Caesar_chiper
    Private Sub Caesar_chiper_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Plainteks.Text = ""
        Chiperteks.Text = ""
    End Sub
    Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.Click
        Dim jumlah As Double = Len(Plainteks.Text)
        Dim x As String
        Dim xkalimat As String = ""
        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 i
        Chiperteks.Text = xkalimat
    End Sub
    Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        End
    End Sub
    Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
        Chiperteks.Text = ""
        Plainteks.Text = ""
    End Sub
    Private Sub Btnkembali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkembali.Click
        Me.Hide()
        Formkriptografi.Show()
    End Sub
End Class

B. Program Gronsfeld Chiper
1. Click Menu File dan Pilih Gronsfeld Chiper
2. Maka akan tampil Program Gronsfeld Chiper



LISTING PROGRAM GRONSFELD_CHIPER

Public Class Gronsfeld
    Private Sub btnkembali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkembali.Click
        Me.Hide()
        Formkriptografi.Show()
    End Sub
    Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
        End
    End Sub
    Private Sub Gronsfeld_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Plainteks.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 String
        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)) - 65
            nEnc = ((nKata + nKunci) Mod 26)
            sPlain = sPlain & Chr((nEnc))
        Next i
        Chiperteks.Text = sPlain
    End Sub
    Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
        Plainteks.Text = ""
        Chiperteks.Text = ""
        Kunci.Text = ""
    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
    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
 

C. Program Vernam Chiper

1. Click Menu File dan Pilih Vernam Chiper
2. Maka akan Muncul Program Vernam Chiper
 
LISTING PROGRAM VERNAM­_CHIPER
Public Class Vernam_chiper
    Private Sub btnkembali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkembali.Click
        Me.Hide()
        Formkriptografi.Show()
    End Sub
    Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        End
    End Sub
    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        Plainteks.Text = ""
        kunci.Text = ""
        Chiperteks.Text = ""
    End Sub
    Private Sub Vernam_chiper_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Plainteks.Text = ""
        Chiperteks.Text = ""
        kunci.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)) - 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
    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
D. Program Vigenere Chiper

 1. Click Menu File Pada Vigenere Chiper

2. Maka akan Muncul Program Vigenere Chiper



LISTING PROGRAM VIGENERE_CHIPER
Public Class Vigenere_chiper
    Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
        Plainteks.Text = ""
        Chiperteks.Text = ""
        kunci.Text = ""
    End Sub
    Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
        End
    End Sub
    Private Sub Btnkembali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkembali.Click
        Me.Hide()
        Formkriptografi.Show()
    End Sub
    Private Sub Vigenere_chiper_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Plainteks.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)) + 0
            nKunci = Asc(Mid(sKey, J, 1)) + 0
            nEnc = ((nKata + nKunci) Mod 256)
            sPlain = sPlain & Chr((nEnc))
        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
    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

E. Program Des Chiper

1. Click Menu File dan Pilih Des Chiper 





2. Maka Akan Muncul Program Des Chiper

LISTING PROGRAM DES_CHIPER
Public Class DES_chiper
    Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
        plainteks.Text = ""
        chiperteks.Text = ""
    End Sub
    Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
        End
    End Sub
    Private Sub Btnkembali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkembali.Click
        Me.Hide()
        Formkriptografi.Show()
    End Sub
    Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.Click
        Dim kunci As String, kunciChar As String, katabaru As String
        Dim Pos As Integer
        Dim i As Integer, Side1 As String, Side2 As String
        Dim nEnc As Integer
        Pos = 1
        For i = 1 To Len(plainteks.Text)
            plainteks.Text = Mid(plainteks.Text, i, 1)
            Kunci.Text = Mid(Kunci.Text, Pos, 1)
            chiperteks.Text = chiperteks.Text & Chr(Asc(Of Char)() Xor Asc(Kunci.Text))
            If Pos = Len(Kunci) Then Pos = 0
            Pos = Pos + 1
        Next i
        If Len(chiperteks.Text) Mod 2 = 0 Then
            Side1 = StrReverse(Left(chiperteks.Text, (Len(chiperteks.Text) / 2)))
            Side2 = StrReverse(Right(chiperteks.Text, (Len(chiperteks.Text) / 2)))
            chiperteks.Text = Side1 & Side2
        End If
        nEnc = chiperteks.Text
    End Sub
End Class
F. Program RC4
1.Click Menu File Pilih RC 4

No comments:

Post a Comment