Skip to main content

Encr_AES_EncryptUsingKey (function reference)

By April 20, 2023April 25th, 2023Online Help, Troi Encryptor Plug-in
Troi Encryptor Plug-in > Functions reference > Encr_AES_EncryptUsingKey
Troi Encryptor Plug-in for FileMaker Pro

Encr_AES_EncryptUsingKey

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

SyntaxFunction badge

Encr_AES_EncryptUsingKey ( switches ; key ; initializationVector ;
                           dataToEncrypt ; {paddingScheme} )

Parameters

switches modifies the behavior of the function
key the key to use
initializationVector the initialization vector (IV) to use (formatted in Base64)
dataToEncrypt the text to encrypt
paddingScheme (optional) the padding to be 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 encrypted text (in base64 encoding) or an error code.

Returned error codes can be:

$$-4244 kErrPwdEmpty no encryption 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 (like PHP-mcrypt). You might want to use the more simple Encr_EncryptAES function.

You use this in conjunction with the Encr_AES_CreateKeyAndIV function (and with the Encr_AES_DecryptUsingKey function to decrypt).

From the length of the key the function will determine if you want AES-128 or AES-256 encryption.

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

See the PHP-mcrypt folder in the download for an example how to decrypt data encrypted with Troi Encryptor Plug-in.

Example

Set Variable [ $EncryptionKey ; "ZTBkMDczYzdkN2NhZDNiMjFmMDM1MTdiOWMwM2Q3ZDg=" ] 
Set Variable [ $InitializationVector ; "eYylMTRugzqcaHrqW7JxQg==" ]
Set Variable [ $OriginalText ; "your text to be made secret" ] 
Set Variable [ $PaddingScheme ; "PKCS7" ]

# Encrypt it:
Set Variable [ $EncryptedText ; Encr_AES_EncryptUsingKey ( "-unused" ; $EncryptionKey ;
			 $InitializationVector ; $OriginalText ; $PaddingScheme ) ]

The result: will be similar to this:
9/0bnrlHqOTojVF2qrmrRw==

Used in example files

EncryptAES.fmp12
OpenSSL.fmp12

Related functionsFunction badge

Encr_AES_CreateKeyAndIV
Encr_AES_DecryptUsingKey
Encr_Code
Encr_EncryptAES

Related topics

Troi Encryptor Plug-in online help (overview)


Online Help Page for Troi Encryptor Plug-in for 16 to 2023 –> Encr_AES_EncryptUsingKey (encrp4320) 2023-0425 15:38:13