Sabtu, 18 Januari 2014

Kriptografi....


Kriptografi


1. Kriptografi Chiper
2. Kriptografi Vernam
3. Kriptografi Gronsfield
4. Kriptografi Vigenere

yang pertama buat menu utamanya seperti dibawah ini
untuk memanggil menu utamanya, berikut adalah listing programnya
Public Class Form2

    Private Sub KiptografiCaesarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiCaesarToolStripMenuItem.Click
        Form1.MdiParent = Me
        Form1.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 KrptografGronsfieldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KrptografGronsfieldToolStripMenuItem.Click
        Form4.MdiParent = Me
        Form4.Show()

    End Sub

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

    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

kemudian desainlah form seperti dibawah ini
untuk kriptografi Chiper
Listing program

Public Class Form1

  
    Private Sub Btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.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 btndeskripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndeskripsi.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
End Class

Maka hasilnya akan terlihat seperti di bawah ini





Untuk Kriptografi Vernam


Listing program

Public Class Form3

    Private Sub OneTimePad_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        plainteks.Text = ""
        kunci.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)) - 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 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

Maka hasilnya akan terlihat,



kemudian Kriptografi Gronsfield
desain form nya seperti di bawah ini...


Listing program

Public Class Form4


    Private Sub Form4_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
        jum = Len(Text)
        splain = ""
        skey = kunci.Text
        skata = 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))
            nEnc = (nkata + nkunci) Mod 26
            splain = splain & Chr((nEnc) + 65)
        Next i
        chiperteks.Text = splain
    End Sub
End Class

Maka hasilnya akan seperti dibawah ini,




yang terakhir Kriptografi Vigenere
desain 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 = ""
        chiperteks.Text = ""
        kunci.Text = ""
    End Sub

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

End Class

Hasilnya terlihat seperti dibawah ini..


Selasa, 14 Januari 2014

penilaian mahasiswa

desain lah form sebagai berikut :


Public Class penilaian

    Private Sub penilaian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        npm.Items.Add("12110443")
        npm.Items.Add("12110549")
        npm.Items.Add("12110331")
        npm.Items.Add("12110884")

        kdosen.Items.Add("MS001")
        kdosen.Items.Add("KS002")
        kdosen.Items.Add("TL003")

        kmatakuliah.Items.Add("VB")
        kmatakuliah.Items.Add("PH")
        kmatakuliah.Items.Add("SDB")

        Dim N As Integer
        For N = 100 To 1 Step -5
            nkehadiran.Items.Add(N)
            ntugas.Items.Add(N)
            nuts.Items.Add(N)
            nuas.Items.Add(N)
        Next

    End Sub

    Private Sub npm_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles npm.SelectedIndexChanged
        Select Case npm.Text
            Case "12110443"
                nama.Text = "Maya Lestari"
                jenjang.Text = "S1"
                jurusan.Text = "Sistem Informasi"
            Case "12110549"
                nama.Text = "Nuri Monika"
                jenjang.Text = "S1"
                jurusan.Text = "Teknik Informatika"
            Case "12110331"
                nama.Text = "Shania Junianatha"
                jenjang.Text = "S1"
                jurusan.Text = "Sistem Informasi"
            Case "12110884"
                nama.Text = "Sonya Pandarmawan"
                jenjang.Text = "D3"
                jurusan.Text = "Manajemen Informatika"
        End Select
    End Sub

    Private Sub kdosen_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kdosen.SelectedIndexChanged
        Select kdosen.Text
            Case "MS001"
                ndosen.Text = "Mesran,M.Kom"
            Case "KS002"
                ndosen.Text = "Kristian Siregar M.kom"
            Case "TL003"
                ndosen.Text = "Toni Limbong,M.Kom"
        End Select
    End Sub

    Private Sub kmatakuliah_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kmatakuliah.SelectedIndexChanged
        Select Case kmatakuliah.Text
            Case "VB"
                mkuliah.Text = "Visual Basic"
            Case "PH"
                mkuliah.Text = "Pemograman HTML"
            Case "SDB"
                mkuliah.Text = "Sistem Basis Data"
        End Select
    End Sub

    Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnproses.Click
        If nakhir.Text = "" Then
            nakhir.Text = 0.1 * nkehadiran.Text + 0.15 * ntugas.Text + 0.3 * nuts.Text + 0.45 * nuas.Text
            nakhir.Focus()
        End If
        If nakhir.Text >= 50 Then
            ket.Text = "Lulus"
        Else
            ket.Text = "Gagal"
        End If
        If nakhir.Text >= 80 Then
            nhuruf.Text = "A"
        ElseIf nakhir.Text >= 70 Then
            nhuruf.Text = "B"
        ElseIf nakhir.Text >= 60 Then
            nhuruf.Text = "C"
        ElseIf nakhir.Text >= 50 Then
            nhuruf.Text = "D"
        Else
            nhuruf.Text = "E"
        End If
    End Sub
    Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        npm.Text = ""
        nama.Text = ""
        jenjang.Text = ""
        jurusan.Text = ""
        kdosen.Text = ""
        ndosen.Text = ""
        kmatakuliah.Text = ""
        mkuliah.Text = ""
        nkehadiran.Text = ""
        ntugas.Text = ""
        nuts.Text = ""
        nuas.Text = ""
        nakhir.Text = ""
        nhuruf.Text = ""
        ket.Text = ""
    End Sub

    Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        Dim tanya As String
        tanya = MsgBox("Apakah Anda Yakin Mau Keluar", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
        If tanya = vbYes Then
            Me.Close()
        Else
            Exit Sub
        End If
    End Sub
End Class

dan hasilnya seperti ini :