Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Module: Encryption in Category General VBA/VB6 : Encryption and Compression from Total Visual SourceBook

Encrypt and decrypt a Unicode or ASCII string using XOR password encryption in VBA and VB6.

Similar to class CEncryption but simplified for function calls and no progress events.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the modEncryption module
EncryptString Procedure Encrypt/Decrypt a string with XOR encryption with support for Unicode. The encrypted string produced by the method is reversible. This means that if you encrypt a string, then encrypt the results of that operation, the original string is restored. Please note that the same password must be supplied to successfully decrypt the string. Please see the example tab for a demonstration of this. If you need an ASCII version of this function, use the EncryptStringAscii method.
EncryptStringAscii Procedure Encrypt/Decrypt a string with XOR encryption, returning the result in ASCII format. The encrypted string produced by the method is reversible. This means that if you encrypt a string, then encrypt the results of that operation, the original string is restored. Please note that the same password must be supplied to successfully decrypt the string. Please see the example tab for a demonstration of this. The EncryptStringAscii method returns the result in ASCII format. If you need to pass the results of the EncryptString function on the command line, or use it external to your program, it is recommended that you use the ASCII version of this function.
EncryptByte Procedure Encrypt one byte, and modify the password. Modifying the password as we encrypt makes the encryption slightly harder to break.

Example Code for Using Module: Encryption

' Example of modEncryption
'
' To use this example, create a new module and paste this code into it.
' Then run the procedure by putting the cursor in the procedure and pressing:
'    F5 to run it, or
'    F8 to step through it line-by-line (see the Debug menu for more options)

Private Sub Example_modEncryption()
  ' Comments: Examples of modEncryption to encrypt and unencrypt a string with a password in VBA and VB6.
  '           See the Immediate Window for the results.

  Const cstrExample As String = "One small step for [a] man; one giant leap for mankind"
  Const cstrPassword As String = "password"

  Dim strString As String

  Debug.Print "Original String: " & cstrExample
  Debug.Print

  ' Example of Unicode encrypting and decrypting strings.
  strString = EncryptString(cstrExample, cstrPassword)
  Debug.Print "Encrypted String: " & strString

  strString = EncryptString(strString, cstrPassword)
  Debug.Print "Un-Encrypted String: " & strString
  Debug.Print

  ' Example of ASCII encrypting and decrypting strings.
  strString = EncryptStringAscii(cstrExample, cstrPassword)
  Debug.Print "ASCII Encrypted String: " & strString

  strString = EncryptStringAscii(strString, cstrPassword)
  Debug.Print "ASCII Un-Encrypted String: " & strString

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources