Vine.docx

  • Uploaded by: mega
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Vine.docx as PDF for free.

More details

  • Words: 312
  • Pages: 2
btnEnkripsi.Click If txtPtext.Text = "" Or txtKey.Text = "" Then MsgBox("tidak boleh kosong!") Else aturKunci("enkrip") For i = 1 To pjgplain pi = Asc(Mid(txtPtext.Text, i)) - 97 k = Asc(Mid(kunci, i)) - 97 ci = (pi + k) Mod 26 d = ci + 97 hsl = hsl + Chr(d) Next i txtChipText.Text = hsl lblHasilEn.Text = hsl hsl = "" End If End Sub Private Sub aturKunci(jenis As String) Dim jns As Integer pjgkey = Len(txtKey.Text) If jenis = "enkrip" Then jns = Len(txtPtext.Text) pjgplain = Len(txtPtext.Text) Else jns = Len(txtChipText.Text) pjgchiper = Len(txtChipText.Text) End If If jns <= pjgkey Then 'kondisi bila inputan kurang dari kunci kunci = txtKey.Text.Substring(0, jns) 'mengambil key sesuai panjang inputan Else kunci = "" For i = 1 To Floor((jns / pjgkey)) kunci = kunci + txtKey.Text Next i i = jns Mod pjgkey If i > 0 Then kunci = kunci + (txtKey.Text.Substring(0, i)) End If End If End Sub Private Sub txtPtext_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPtext.KeyPress e.KeyChar = LCase(e.KeyChar) 'lower abjad menjadi kecil Dim KeyAscii As Short = Asc(e.KeyChar) If (e.KeyChar Like "[A-Za-z]" _ OrElse KeyAscii = Keys.Back _ OrElse KeyAscii = Keys.Return _ OrElse KeyAscii = Keys.Delete) Then KeyAscii = 0 End If e.Handled = CBool(KeyAscii) End Sub

Private Sub txtKey_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtKey.KeyPress e.KeyChar = LCase(e.KeyChar) Dim KeyAscii As Short = Asc(e.KeyChar) If (e.KeyChar Like "[A-Za-z]" _ OrElse KeyAscii = Keys.Back _ OrElse KeyAscii = Keys.Return _ OrElse KeyAscii = Keys.Delete) Then KeyAscii = 0 End If e.Handled = CBool(KeyAscii) End Sub Private Sub txtChipText_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtChipText.KeyPress e.KeyChar = LCase(e.KeyChar) Dim KeyAscii As Short = Asc(e.KeyChar) If (e.KeyChar Like "[A-Za-z]" _ OrElse KeyAscii = Keys.Back _ OrElse KeyAscii = Keys.Return _ OrElse KeyAscii = Keys.Delete) Then KeyAscii = 0 End If e.Handled = CBool(KeyAscii) End Sub End Class

aaaaaaaaaaaaaaaaaaaaaaaa

More Documents from "mega"

Vine.docx
December 2019 83
Friendly Kasus Ham.docx
December 2019 79
Bab 4 Dan 5 - Copy.docx
November 2019 55
2.docx
December 2019 40
Cr Cardiovaskuler.docx
November 2019 45