Sabtu, 18 Januari 2014

KRIPTOGRAFI

                                  Koding Kriptografi Caesar
 

Public Class kriptografi_caesar
    Private Sub Enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enkripsi.Click
        Dim x As String = ""
        Dim xkalimat As String = ""
        For i = 1 To Len(plain.Text)
            x = Mid(plain.Text, i, i)
            x = Chr(Asc(x) + 3)
            xkalimat = xkalimat + x
        Next
        chiper.Text = xkalimat
    End Sub

    Private Sub deskrifsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deskrifsi.Click
        Dim f As String = ""
        Dim xisi As String = ""
        For m = 1 To Len(plain.Text)
            f = Mid(plain.Text, m, m)
            f = Chr(Asc(f) - 3)
            xisi = xisi + f
        Next
        chiper.Text = xisi
    End Sub
End Class






Koding Kriptografi Vernam

Public Class kriptografi_vernan
    Private Sub kriptografi_vernan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plain.Text = ""
        kunci.Text = ""
        chiper.Text = ""
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 = plain.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 65)
            splain = splain & Chr((nenc) + 65)

        Next i
        chiper.Text = splain
    End Sub

    Private Sub plain_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles plain.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

Koding Kriptografi Grosfeld
   
Public Class kriptografi_grosfeld

    Private Sub kriptografi_grosfeld_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plain.Text = ""
        kunci.Text = ""
        chiper.Text = ""
    End Sub

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

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

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 = plain.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
        chiper.Text = sPlain
    End Sub
End Class


 
Koding Kriptografi Vigenere

Public Class kriptografi_vigenere
    Private Sub kriptografi_vigenere_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plain.Text = ""
        chiper.Text = ""
        kunci.Text = ""
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 = plain.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
        chiper.Text = sPlain
    End Sub

PROGRAM PENGGAJIAN KARYAWAN


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        nik.Items.Add("PM010")
        nik.Items.Add("PS111")
        nik.Items.Add("KU101")
        nik.Items.Add("GD100")
        nik.Items.Add("PM011")
        jabatan.Items.Add("Kepala Divisi")
        jabatan.Items.Add("Staff")
        jabatan.Items.Add("Wakil")
        Status.Items.Add("Menikah")
        Status.Items.Add("Tidak Menikah")
        jumlah_anak.Items.Add("1 Anak")
        jumlah_anak.Items.Add("2 Anak")
        Call pembagian()
        Call penamaan()
        Call gapok()
    End Sub

    Sub pembagian()
        Dim x As String
        x = Microsoft.VisualBasic.Left(nik.Text, 2)
        Select Case x
            Case "PM"
                bagian.Text = "Pemasaran"
            Case "PS"
                bagian.Text = "Personalia"
            Case "KU"
                bagian.Text = "Keuangan"
            Case "GD"
                bagian.Text = "Gudang"
        End Select
    End Sub

    Sub penamaan()
        Select Case nik.Text
            Case "PM010"
                nama.Text = "Doni Sutejo"
            Case "PS111"
                nama.Text = "Bambang Kodek"
            Case "KU101"
                nama.Text = "Sutan Mulia"
            Case "GD100"
                nama.Text = "Muhammad Lego"
            Case "PM011"
                nama.Text = "Abed Nego"
        End Select
    End Sub

    Sub gapok()
        Select Case jabatan.Text
            Case "Kepala Divisi"
                gaji_pokok.Text = "5000000"
            Case "Staff"
                gaji_pokok.Text = "2000000"
            Case "Wakil"
                gaji_pokok.Text = "3500000"
        End Select
    End Sub

    Sub TunjanganAnak()
        Select Case jumlah_anak.Text
            Case "1 Anak"
                tunjangan_anak.Text = 0.05 * gaji_pokok.Text
            Case "2 Anak"
                tunjangan_anak.Text = 0.1 * gaji_pokok.Text
        End Select
        Call totalGaji()
    End Sub
    Sub TunjanganKeluarga()
        Select Case Status.Text
            Case "Menikah"
                tunjangan_keluarga.Text = 0.15 * gaji_pokok.Text
            Case "Tidak Menikah"
                tunjangan_keluarga.Text = "0"
        End Select
    End Sub
    Sub totalGaji()
        total_gaji.Text = "Rp " & Val(gaji_pokok.Text) + Val(tunjangan_keluarga.Text) + Val(tunjangan_anak.Text) - Val(Pajak.Text)
    End Sub
    Sub hapus()
        nik.Text = ""
        nama.Text = ""
        bagian.Text = ""
        jabatan.Text = ""
        gaji_pokok.Text = ""
        Pajak.Text = ""
        Status.Text = ""
        jumlah_anak.Text = ""
        tunjangan_keluarga.Text = ""
        tunjangan_anak.Text = ""
        total_gaji.Text = ""
    End Sub

    Private Sub nik_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nik.SelectedIndexChanged
        Call pembagian()
        Call penamaan()
    End Sub
    Private Sub jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jabatan.SelectedIndexChanged
        Call gapok()
        Pajak.Text = gaji_pokok.Text * 0.1
    End Sub
    Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click
        End
    End Sub

    Private Sub jumlah_anak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah_anak.SelectedIndexChanged
        Call TunjanganAnak()
    End Sub

    Private Sub Status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Status.SelectedIndexChanged
        Call TunjanganKeluarga()
        Call totalGaji()
    End Sub

    Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapus.Click
        Call hapus()
    End Sub
End Class