Encr_AES_DecryptUsingKey (function reference)

By February 1, 2019June 10th, 2020Online Help, Troi Encryptor Plug-in
Troi Encryptor Plug-in > Functions reference > Encr_AES_DecryptUsingKey
Troi Encryptor Plug-in for FileMaker Pro

Encr_AES_DecryptUsingKey

Decrypts data with AES using an encryption key and initialization vector.

SyntaxFunction badge

Encr_AES_DecryptUsingKey ( switches ; key ; initializationVector;
                           dataToDecrypt ; {paddingScheme} )

Parameters

switches modifies the behavior of the function
key the key to use
initializationVector the initialization vector (IV) to use (formatted in Base64)
dataToDecrypt the text to decrypt
paddingScheme (optional) the padding that was used, can be: PKCS7 (default) or ZeroPadding

Switches

You can add one or more of these switches to retrieve extra information:

-AddSaltInfo add the used Salt at the end of the result (need not be kept secret)

Other switches are not (yet) possible.

Returned Result

Data type returned

Text

Result

the decrypted text or an error code.

Returned error codes can be:

$$-4244 kErrPwdEmpty no decryption key was given
$$-50 paramErr Parameter error (incorrect key size or IV size given)

Originated in

Troi Encryptor Plug-in 3.0

Compatibility

FileMaker Pro 15 to 19

Considerations

This is an advanced function, for exchanging data with other systems. You might want to use the more simple Encr_DecryptAES function.

You use this in conjunction with the Encr_AES_CreateKeyAndIV function (and to encrypt the Encr_AES_EncryptUsingKey function).

Technical details:
AES-128: 128 bit, CBC with a 16 byte key. Blocksize is 16 byte so the IV is 16 byte.
AES-256: 256 bit, CBC with a 32 byte key. Blocksize is also 16 byte so the IV is 16 byte.

Example

Use the result of the Encr_AES_CreateKeyAndIV function to fill the following variables:

Set Variable [ $EncryptionKey ; "ZTBkMDczYzdkN2NhZDNiMjFmMDM1MTdiOWMwM2Q3ZDg=" ] 
Set Variable [ $InitializationVector ; "eYylMTRugzqcaHrqW7JxQg==" ]

Also set the following variables:

Set Variable [ $OriginalText ; "9/0bnrlHqOTojVF2qrmrRw== " ] 
Set Variable [ $PaddingScheme ; "PKCS7" ]

Then decrypt it:

Set Variable [ $DecryptedText ; Encr_AES_DecryptUsingKey ( "-unused" ; $EncryptionKey ; 
			$InitializationVector ; $OriginalText ; $PaddingScheme ) ]

The result will be the original data, for example:
“your text to be made secret”

If the key or iv is different from the encryption the result will be random data.

Related functionsFunction badge

Encr_AES_CreateKeyAndIV
Encr_AES_EncryptUsingKey
Encr_Code
Encr_EncryptAES

Related topics

Troi Encryptor Plug-in online help (overview)


Online Help Page for Troi Encryptor Plug-in for 15 to 19 –> Encr_AES_DecryptUsingKey (encrp4321) 2020-0610 16:17:39