• Tuesday, June 17, 2014

    VB6:How to Encrypt/Decrypt string or text.

    You can use this function for encrypt or decrypt string... One time it encrypt and another time it decrypt.

    Private Function encdec(str As String) As String

    Dim a As String, b As Integer, c As String
    For i= 1 To len(str)
      a = mid(str, i, 1)
      b = Asc(a) Xor 63 'You can use any number for encrypt from 1 to 255
      c =  c & Chr(b)
    Next i
    encdec = c
    End Function

    Place two Command Button name them: cmdEncrypt , cmdDecrypt
    Place a text box and change it property multiline = true
    Open code window by double clicking on form. Copy the above code and paste on that windows at last.
    Copy the below code and paste on that same window at last...
    Run your project.........

    Private Sub cmdEncrypt_Click()
      text1.text = endec(text1.text)
    End Sub

    Private Sub cmdDecrypt_Click()
      text1.text= encdec(text1.text)
    End Sub

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)


    Post a Comment