Encr_AES_DecryptUsingKey | 
Decrypts data with AES using an encryption key and initialization vector.
Syntax
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 16 to FileMaker Pro 2023
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.
Used in example files
EncryptAES.fmp12
OpenSSL.fmp12
Related functions
| Encr_AES_CreateKeyAndIV | 
| Encr_AES_EncryptUsingKey | 
| Encr_Code | 
| Encr_EncryptAES | 
Related topics
Troi Encryptor Plug-in online help (overview)