Visual Basic


  1. Program Enkripsi – Dekripsi dengan Visual Basic 6

27 responses to “Visual Basic”

  1. kak nunu… aku mo tanya neh… tentang kriptography…. mo sharing masalah prigram VB ini. ku bikin program, ini sourcenya tapi ada yang ga kutau :

    Private Function Encrypt(kata As String, kunci As String)
    Dim Char As String, kunciChar As String, katabaru As String
    Dim Pos As Integer
    Dim i As Integer, Side1 As String, Side2 As String
    Pos = 1

    For i = 1 To Len(kata)
    Char = Mid(kata, i, 1)
    kunciChar = Mid(kunci, Pos, 1)
    katabaru = katabaru & Chr(Asc(Char) Xor Asc(kunciChar))

    If Pos = Len(kunci) Then Pos = 0
    Pos = Pos + 1
    Next i
    If Len(katabaru) Mod 2 = 0 Then
    Side1 = StrReverse(Left(katabaru, (Len(katabaru) / 2)))
    Side2 = StrReverse(Right(katabaru, (Len(katabaru) / 2)))
    katabaru = Side1 & Side2
    End If
    Encrypt = katabaru
    End Function

    baris 7-13 itu artinya apa ya? ku lupa… masalah for itu.
    tnx alot ya mas….

    • yang ini maksudnya :

      For i = 1 To Len(kata)
      ……
      ……
      dan seterusnya
      ———————

      ini perulangan sebanyak panjang kata .. ingat Len, mencari panjang kata (hasil : integer).

      Mid(string, integer, integer) .. ini merupakan operasi string yang nantinya menghasilkan string. jadi bila :

      KunciChar = Mid(kunci, Pos, 1)

      berarti mengambil huruf dari string kunci pada index ke Pos sebanyak 1.

      dan seterusnya …..
      untuk lebih baiknya, silakan kirim source lengkapnya, nanti saya tuliskan penjelasannya. klik disini .. kirim

  2. tolong jlasin listing dari program ini, coz udh saya compile tp masih ada errornya, tolong y?

    Private crcTable(0 To 255) As Long ‘crc32

    Public Function CRC32(ByRef bArrayIn() As Byte, ByVal lLen As Long, Optional ByVal lcrc As Long = 0) As Long

    ‘bArrayIn adalah array byte dari file yang dibaca, lLen adalah ukuran atau size file

    Dim lCurPos As Long ‘Current position untuk iterasi proses array bArrayIn

    Dim lTemp As Long ‘variabel temp hasil perhitungan

    If lLen = 0 Then Exit Function ‘keluar fungsi apabila ukuran file = 0

    lTemp = lcrc Xor &HFFFFFFFF

    For lCurPos = 0 To lLen

    lTemp = (((lTemp And &HFFFFFF00) \\ &H100) And &HFFFFFF) Xor (crcTable((lTemp And 255) Xor bArrayIn(lCurPos)))

    Next lCurPos

    CRC32 = lTemp Xor &HFFFFFFFF

    End Function

    Private Function BuildTable() As Boolean

    Dim i As Long, x As Long, crc As Long

    Const Limit = &HEDB88320

    For i = 0 To 255

    crc = i

    For x = 0 To 7

    If crc And 1 Then

    crc = (((crc And &HFFFFFFFE) \\ 2) And &H7FFFFFFF) Xor Limit

    Else

    crc = ((crc And &HFFFFFFFE) \\ 2) And &H7FFFFFFF

    End If

    Next x

    crcTable(i) = crc

    Next i

    End Function

    Private Sub Class_Initialize()

    BuildTable

    End Sub

  3. mas tolong bntu sya gmn cra ngitung alogaritmanya bingung neh…

    Private Function RC4(ByVal Str As String, ByVal Pwd As String) As String
    On Error Resume Next
    Dim Sbox(0 To 255) As Integer
    Dim A
    Dim B
    Dim C
    Dim Key() As Byte
    Dim ByteArray() As Byte
    Dim Tmp As Byte
    If Len(Pwd) = 0 Or Len(Str) = 0 Then Exit Function

    If Len(Pwd) > 256 Then
    Key() = StrConv(Left$(Pwd, 256), vbFromUnicode)
    Else
    Key() = StrConv(Pwd, vbFromUnicode)
    End If

    For A = 0 To 255
    Sbox(A) = A
    Next A
    A = 0
    B = 0
    C = 0
    For A = 0 To 255
    B = (B + Sbox(A) + Key(A Mod Len(Pwd))) Mod 256
    Tmp = Sbox(A)
    Sbox(A) = Sbox(B)
    Sbox(B) = Tmp
    Next A
    A = 0
    B = 0
    C = 0
    ByteArray() = StrConv(Str, vbFromUnicode)
    For A = 0 To Len(Str)
    B = (B + 1) Mod 256
    C = (C + Sbox(B)) Mod 256
    Tmp = Sbox(B)
    Sbox(B) = Sbox(C)
    Sbox(C) = Tmp
    ByteArray(A) = ByteArray(A) Xor (Sbox((Sbox(B) + Sbox(C)) Mod 256))
    Next A
    RC4 = StrConv(ByteArray, vbUnicode)
    End Function

  4. kalau ini artinya apa yaa…

    Private Sub cmd_enkrip_Click()
    Dim Enkrip, Output, Inputan As String
    Dim Panjang_Input As Integer
    Inputan = Text1.Text
    Panjang_Input = Len(Text1.Text)
    For i = 1 To Panjang_Input
    Enkrip = Mid(Inputan, i, 1)
    Enkrip = Asc(Enkrip)
    Enkrip = (Enkrip + 5) – 13
    Enkrip = Chr(Enkrip)
    Output = Output & Enkrip
    Next i
    Text2.Text = Output
    End Sub

    Private Sub cmd_dekrip_Click()
    Dim Dekrip, Output, Inputan As String
    Dim Panjang_Input, Pesan As Integer
    Inputan = Text3.Text
    Panjang_Input = Len(Text3.Text)
    For i = 1 To Panjang_Input
    Dekrip = Mid(Inputan, i, 1)
    Dekrip = Asc(Dekrip)
    Dekrip = (Dekrip – 5) + 13
    Dekrip = Chr(Dekrip)
    Output = Output & Dekrip
    Next i
    Text4.Text = Output
    End Sub

    Private Sub cmd_hapus_Click()
    Text1.Text = “”
    Text2.Text = “”
    Text3.Text = “”
    Text4.Text = “”
    End Sub

    Private Sub Command3_Click()
    End
    End Sub

  5. salam kenal,mau tanya donk mengenai source code berikut:

    Private Sub Command1_Click()
    Dim text1aja As String
    Dim pos As Integer

    text1aja = Text1
    For pos = 1 To Len(text1aja)
    Mid(text1aja, pos, 1) = Chr(((Asc(Mid(text1aja, pos, 1)) * 4) 7) + 2)
    Next pos
    Text2 = text1aja
    End Sub

    Private Sub Command2_Click()
    Dim text1aja As String
    Dim pos As Integer

    text1aja = Text2
    For pos = 1 To Len(text1aja)
    Mid(text1aja, pos, 1) = Chr((Asc(Mid(text1aja, pos, 1)) – 2) 2)
    Next pos
    Text1 = text1aja
    End Sub

    saya mau minta penjelasan lengkap nya,per perintahnya, makasih sebelumnya :)

  6. kak nunu .. kalo hasilnya kyak gini

    akan menghasilkan 1 sampai 10, kemudian program melompat ke label akhir dan mencetak SELESAI

    itu rumusnya bagai mana
    please replay :)

Leave a Reply