Understanding Basic Encryption and Decryption

After you have a key, either derived or generated, you can use that key to encrypt or decrypt data. When you have your keys, your application will spend most of its time encrypting or decrypting. This is actually a simple matter of calling one of two functions.

Encrypting Data

You encrypt data by using the CryptEncrypt function. This function is declared as follows:

 Public Declare Function CryptEncrypt Lib "advapi32.dll" ( _
    ByVal hKey As Long, ByVal hHash As Long, _
    ByVal Final As Long, ByVal dwFlags As Long, _
    ByVal pbData As String, pdwDataLen As Long, _
    ByVal dwBufLen As Long) As Long

The first parameter (hKey) for this function is the handle of the encryption key to be used to en- crypt the ...

Get Developing Secure Applications with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.