This sample demonstrates how to encrypt and decrypt a block of memory data using both symmetric and public-key encryption methods.
Project path: SAMPLES\VISUAL BASIC 6\MEMORYENCRYPT
Project file name: MEMORYENCRYPT.VBP
Properties: HashingMethod, EncryptionMode, PaddingMethod, EncryptionMethod, PrivateKey and PublicKey.
Methods: Encrypt, Decrypt, SetSecretKeyFromPassPhrase and SetRandomInitVector
Select the encryption method using one of the two radio buttons, Symmetric or Asymmetric (for public-key encryption ).
The Symmetric encryption button uses the text you specify in the Pass phrase text box to create the secret key. You can click the "Option" button to set the encryption format (Rijndael or Twofish), the encryption mode, the key size, the hashing method and the padding method.
The Asymmetric encryption button uses the file name you specify in the two text boxes and read from them the private key and the public key. You can create a new key pair by clicking the "Set random key pair" button. A form will pop-up where you will be able to enter the wanted key pair size (in bits). By default, a value of 1024 is provided. You can also specify a seed text which the random generator will use when creating the key pair. The private and the public key will be saved in the files entered in the main form.