This sample demonstrates how to encrypt and decrypt a block of memory data using different kinds of encryption methods.
Project path: SAMPLES\DELPHI 4-7\MEMORYENCRYPT
Project file name: MEMENCRYPT.DPR
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 and Asymmetric).
You can either enter the text you wish to encrypt in the "Decrypted text" text box and click on the Encrypt button, or, you can enter the encrypted text in hexadecimal you wish to decrypt in the "Encrypted text" text box and click on the Decrypt button.
The Symmetric encryption 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 method (Rijndael or Twofish), the encryption mode, the key size, the hashing method and the padding method.
The Asymmetric encryption uses the file names 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.