The information in this article applies to:
SUMMARY
It is sometimes desirable to restrict the visibility of string constants
within a Microsoft Visual Basic compiled application. In many cases, string
constants remain in a linear, unencrypted form that debug/editor utilities
can display.
MORE INFORMATION
Software tools for debugging and viewing binary code can easily find ASCII
strings stored in compiled executable .EXE programs. If you want to hide or
protect strings in .EXE programs, you can use techniques such as these:
Example of String Encryption Using Xor FunctionCalling the Encrypt routine below encrypts a string using a password. Calling the Encrypt routine a second time decrypts the encrypted string.
Xor: The Exclusive-OR OperatorThe exclusive-OR operator (Xor in the Basic language) performs a logical exclusion on two expressions. For example:
A useful behavior of Xor is that the first expression expr1 is returned without losing any bits when you perform Result Xor expr2. This ability to restore the first expression from the Result combined with the second expression is why the Xor function is useful for encryption. The Xor operator performs a bit-wise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in the result according to the following truth table:
ASCII and ANSI Character SetsFor a listing of the ASCII and ANSI character sets, see the Help menu in Visual Basic.American Standard Code for Information Interchange (ASCII) is the 7-bit character set widely used to represent letters and symbols found on a standard United States keyboard. The ASCII character set is the same as the first 128 characters (0 to 127) in the American National Standards Institute (ANSI) character set. The ANSI character set uses all 8 bits in a byte, and includes 256 characters (0 to 255). ANSI characters 128 to 255 are sometimes referred to as the extended-ASCII characters. REFERENCES
The following company offers encryption software and other products for
Basic:
Keywords : kb3rdparty kbcode kbVBp400 kbVBp500 kbhowto PrgOther VB4WIN vbwin |
Last Reviewed: May 24, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |