Sabtu, 18 Januari 2014

Project VB - Link Program Kriptografi

Berikut ini merupakan contoh project VB untuk me-Link kan beberapa program Kriptografi ;

Tampilan Menu :
Design form  :







listing program :
Public Class Form1

    Private Sub KriptografiCaesarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiCaesarToolStripMenuItem.Click
        Form2.MdiParent = Me
        Form2.Show()
    End Sub

    Private Sub KriptografiVernamToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVernamToolStripMenuItem.Click
        Form3.MdiParent = Me
        Form3.Show()
    End Sub

    Private Sub KriptografiGronsfeldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiGronsfeldToolStripMenuItem.Click
        Form4.MdiParent = Me
        Form4.Show()
    End Sub

    Private Sub KriptografiVigenereToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVigenereToolStripMenuItem.Click
        Form5.MdiParent = Me
        Form5.Show()
    End Sub

    Private Sub KeluarProgramToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarProgramToolStripMenuItem.Click
        End
    End Sub
End Class


1. KRIPTOGRAFI CAESAR

Design Form :
listing program :

Public Class Form2

    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(plainteks.Text)
            x = Mid(plainteks.Text, i, i)
            x = Chr(Asc(x) + 3)
            xkalimat = xkalimat + x
        Next
        chiperteks.Text = xkalimat

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As String = ""
        Dim xkalimat As String = ""
        For i = 1 To Len(chiperteks.Text)
            x = Mid(chiperteks.Text, i, i)
            x = Chr(Asc(x) - 3)
            xkalimat = xkalimat + x
        Next
        plainteks.Text = xkalimat
    End Sub

End Class

Hasil Program :












2. KRIPTOGRAFI VERNAM

Design form :



listing program :

Public Class Form3

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

    Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkripsi.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 plain_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 key_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

Hasil Program :





3. KRIPTOGRAFI GRONSFELD

Design form :
listing program :

Public Class Form4

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

    Private Sub enkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enkripsi.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 plainteks_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles plainteks.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

End Class

Hasil Program :


4. KRIPTOGRAFI VIGENERE

design form :



listing program :

Public Class Form5

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

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

        chiperteks.Text = sPlain

    End Sub
End Class

Hasil Program :
Demikian disampaikan, terimakasih... :)


Project VB - Form Gaji Karyawan


Berikut ini merupakan salah satu project VB yaitu Form Gaji Karyawan ;

Design form seperti gambar dibawah ini :






listing program :

Public Class Form1


    Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
        nik.Text = ""
        nama.Text = ""
        bagian.Text = ""
        jabatan.Text = ""
        gajipokok.Text = ""
        pajak.Text = ""
        status.Text = ""
        jumlahanak.Text = ""
        tunjangankeluarga.Text = ""
        tunjangananak.Text = ""
        totalgaji.Text = ""
    End Sub

    Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        End
    End Sub

    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")
        jabatan.Items.Add("kepala divisi")
        jabatan.Items.Add("staff")
        jabatan.Items.Add("wakil kepala")
        status.Items.Add("menikah")
        status.Items.Add("tidak menikah")

        Dim x As Byte
        For x = 1 To 5
            jumlahanak.Items.Add(x)
        Next

    End Sub

    Private Sub nik_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nik.SelectedIndexChanged
        Select Case nik.Text
            Case "PM010"
                nama.Text = "apry"
            Case "PS111"
                nama.Text = "anita"
            Case "KU101"
                nama.Text = "tampubolon"
            Case "GD100"
                nama.Text = "aprilia"
            Case "PM011"
                nama.Text = "anitati"
        End Select

        Dim x As String
        x = Microsoft.VisualBasic.Left(nik.Text, 2)
        If x = "PM" Then
            bagian.Text = "Pemasaran"
        ElseIf x = "PS" Then
            bagian.Text = "Personalia"
        ElseIf x = "KU" Then
            bagian.Text = "Keuangan"
        ElseIf x = "GD" Then
            bagian.Text = "Gudang"
        End If

    End Sub

    Private Sub jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jabatan.SelectedIndexChanged
        Select Case jabatan.Text
            Case "kepala divisi"
                gajipokok.Text = 5000000
            Case "staff"
                gajipokok.Text = 2000000
            Case "wakil kepala"
                gajipokok.Text = 3500000
        End Select
        pajak.Text = 0.1 * gajipokok.Text

    End Sub

    Private Sub status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles status.SelectedIndexChanged
        If status.Text = "menikah" Then
            tunjangankeluarga.Text = 0.15 * gajipokok.Text
        Else
            tunjangankeluarga.Text = 0
        End If
    End Sub

    Private Sub jumlahanak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlahanak.SelectedIndexChanged
        If jumlahanak.Text = 1 Then
            tunjangananak.Text = 0.05 * gajipokok.Text
        Else
            tunjangananak.Text = 0.1 * gajipokok.Text
        End If

        totalgaji.Text = Val(gajipokok.Text) + Val(tunjangankeluarga.Text) + Val(tunjangananak.Text) - Val(pajak.Text)

    End Sub
End Class


Maka hasil tampilan seperti berikut :



Demikian disampaikan, terimakasih.... :))