This content is not currently approved and is visible here for review only.

Library code snippets

Encryption

Code

This is a basic code to encrypt/decrypt any texts


add 2 commandbuttons called cmdDecrypt and cmdEncrypt and add 2 text boxes called TxtEncrypt and TxtDecrypt.
then paste the following code to your form.


Private Sub cmdEncrypt_Click()
    For i = 1 To Len(TxtEncrypt.Text)
    ChrCodeIntEncryptt = (Asc(Mid(TxtEncrypt.Text, i, 1)))
    If ChrCodeIntEncryptt > 186 Then
    RemainsEncrypt = 255 - ChrCodeIntEncryptt
    ChrCodeIntEncryptt = -1 + RemainsEncrypt
    Encryptt = Encryptt & Chr(ChrCodeIntEncryptt)
    Else
    Encryptt = Encryptt & Chr(Asc(Mid(TxtEncrypt.Text, i, 1)) + 69)
    End If
    Next i
    TxtDecrypt.Text = Encryptt
End Sub

Private Sub cmdDecrypt_Click()
    For i = 1 To Len(TxtDecrypt.Text)
    ChrCodeIntDecryptt = (Asc(Mid(TxtDecrypt.Text, i, 1)))
    If ChrCodeIntDecryptt < 69 Then
    RemainsDecrypt = 69 - ChrCodeIntDecryptt
    ChrCodeIntDecryptt = 256 - RemainsDecrypt
    Decryptt = Decryptt + Chr(ChrCodeIntDecryptt)
    Else
    Decryptt = Decryptt + Chr(Asc(Mid(TxtDecrypt.Text, i, 1)) - 69)
    End If
    Next i
    TxtEncrypt.Text = Decryptt
End Sub




Now you can use the encrypt button to change the piece of text in txtencrypt into a encrypted text in txtdecrypt and the other way around.

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Encryption.

Leave a comment

Sign in or Join us (it's free).