PSS ID Number: 110308
Article Last Modified on 7/1/2004
A$ = Chr$(65) + Chr$(66) + Chr$(67) + Chr$(68)
Print A$
This code prints ABCD. Because the ABCD is stored in code instead of in
a string constant, it is not directly visible when viewed in a debugger. This
method is okay for small amounts of data, but is inefficient for larger
strings.
Sub Form_Load ()
form1.Show ' Must Show form in Load event before Print is visible.
secret$ = "This is the string that will be encrypted."
PassWord$ = "password"
Call Encrypt(secret$, PassWord$) 'Encrypt the string.
Print " After encrypting it once: " 'Print the result.
Print secret$
Print
Call Encrypt(secret$, PassWord$) 'A second call to the Encrypt
Print "After a second encryption:" 'subroutine now decrypts the
Print secret$ 'encrypted string.
End Sub
Sub Encrypt (secret$, PassWord$)
' secret$ = the string you wish to encrypt or decrypt.
' PassWord$ = the password with which to encrypt the string.
L = Len(PassWord$)
For X = 1 To Len(secret$)
Char = Asc(Mid$(PassWord$, (X Mod L) - L * ((X Mod L) = 0), 1))
Mid$(secret$, X, 1) = Chr$(Asc(Mid$(secret$, X, 1)) Xor Char)
Next
End Sub
Result = expr1 Xor expr2
If bit in expr1 is: And bit in expr2 is: The result is:
---------------------------------------------------------------
0 0 0
0 1 1
1 0 1
1 1 0
Keywords: kb3rdparty kbcode kbhowto KB110308
Technology: kbAudDeveloper kbVB16bitSearch kbVB400 kbVB400Search kbVB500 kbVB500Search kbVBA500Search kbVBSearch kbZNotKeyword2 kbZNotKeyword3 kbZNotKeyword6