Encr_AES_EncryptUsingKey (function reference)

By August 1, 2017 April 3rd, 2018 Online 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

switchesmodifies the behavior of the function
keythe key to use
initializationVectorthe initialization vector (IV) to use (formatted in Base64)
dataToEncryptthe 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:

-AddSaltInfoadd 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:

$$-4244kErrPwdEmptyno encryption key was given
$$-50paramErrParameter error (incorrect key size or IV size given)

Originated in

Troi Encryptor Plug-in 3.0

Compatibility

FileMaker Pro 12 to 16

Considerations

This is an advanced function, for exchanging data with other systems (like PHP-mcrypt). You might want to use the more simple Encr_EncryptRijndaelAES 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==

Related functionsFunction badge

Encr_AES_CreateKeyAndIV
Encr_AES_DecryptUsingKey
Encr_Code
Encr_EncryptRijndaelAES

Related topics

Troi Encryptor Plug-in online help (overview)


Online Help Page for Troi Encryptor Plug-in for 12 to 16 –> Encr_AES_EncryptUsingKey (encrp4320) 2017-0814 18:20:52