Crypt Class Example

The following examples display the use of some Crypt class methods and properties.

An example of encryption program:

&EncryptProfile = "<ENCRYPTPRFL>";
&Encrypt = CreateObject("Crypt");
&Encrypt.Open(&EncryptProfile);
/* If desired you can override any of the Profile Parameters.
Should only be needed if Random IV, KEY, AAD, AUTHTAG are 
used during Encryption.  You must uncomment and
set GoToStep if you uncomment any SetParameter */
rem   &Encrypt.GoToStep(n); /* Change n to Step number in encryption chain */
rem   &Encrypt.SetParameter('IV', '<hex IV used during Encryption>');
rem   &Encrypt.SetParameter('SYMMETRICKEY', '<keyset entry name used during Encryption>');
rem   &Encrypt.SetParameter('AAD', '<AAD value used during Encryption>');
/* Refer to the Documentation for Parameter Names and Values for the non-symmetric algorithms */
rem   &Encrypt.SetParameter('<PARMNAME>', '<PARMVALUE>');
&Encrypt.UpdateData(&rec.<FIELDNAME>.Value);
&EncryptResult = &Encrypt.Result;
rem &Verify = &Encrypt.Verify; /* Used when running Verify routine */
rem &AuthTag = &Encrypt.AuthTag; /* Produced from AES CCM and GCM modes - required for decryption */

An example of decryption program:

&DecryptProfile = "<DECRYPTPRFL>";
&Decrypt = CreateObject("Crypt");
&Decrypt.Open(&DecryptProfile);
/* If desired you can override any of the Profile Parameters.
Should only be needed if Random IV, KEY, AAD, AUTHTAG were 
used/produced during Encryption. You must uncomment and
set GoToStep if you uncomment any SetParameter */
rem   &Decrypt.GoToStep(n); /* Change n to Step number in decryption chain */
rem   &Decrypt.SetParameter('IV', '<hex IV used during Encryption>');
rem   &Decrypt.SetParameter('SYMMETRICKEY', '<keyset entry name used during Encryption>');
rem   &Decrypt.SetParameter('AUTHTAG', '<hex AuthTag produced during Encryption>');
rem   &Decrypt.SetParameter('AAD', '<AAD value used during Encryption>');
/* Refer to the Documentation for Parameter Names and Values 
for the non-symmetric algorithms */
rem   &Decrypt.SetParameter('<PARMNAME>', '<PARMVALUE>');
&Decrypt.UpdateData(&EncryptResult);
&DecryptResult = &Decrypt.Result;