Library code snippets
Encryption
By Jelle Hoekstra, published on 22 May 2006
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.
Related articles
Related discussion
-
Key_Press() event for text box
by Aquila (1 replies)
-
Regarding Visual Basic Programme
by manjunathsl2007 (0 replies)
-
how do you hide all in VB6
by CapnJack (1 replies)
-
Problem with Input File
by novavb6 (3 replies)
-
How to produce a txt file with a table??
by novavb6 (1 replies)
This thread is for discussions of Encryption.