Encr_DecryptAES (function reference)

By February 1, 2019 February 12th, 2019 Online Help, Troi Encryptor Plug-in
Troi Encryptor Plug-in for FileMaker Pro

Encr_DecryptAES

Decrypts text using the AES algorithm and the password.

SyntaxFunction badge

Encr_DecryptAES ( switches ; password ; text )

Parameters

switchesmodifies the behavior of the function
passwordthe password to use
textthe text to decrypt

Switches

-OpenSSLCompatibledecrypt OpenSSL encrypted data
-KeySize=256tells the plug-in a 256 bit key was used during encryption (for OpenSSL)
-HashIterationCount=nspecify the hash iteration count used to generate the key and initialization vector (for OpenSSL)
-DontInterpretAsUTF8don’t interpret the text as UTF-8 (for OpenSSL)

Returned Result

Data type returned

Text

Result

the decrypted text or container data or an error code.

Returned error codes can be:

$$-4244no password was given

Originated in

Troi Encryptor Plug-in 1.2

Compatibility

FileMaker Pro 14 to 17

Considerations

NOTE The Encr_DecryptAES function was called Encr_DecryptRijndaelAES in older versions of the plug-in.

– Be sure to remember the password (case sensitive!): without it you can not retrieve the original text.
– The result field should be the same type as the original field that was encrypted.
See Encr_EncryptAES for more technical information on the AES implementation.

About OpenSSL compatibility (introduced with Troi Encryptor 5.0):

When you use the -OpenSSLCompatible switch, the text to decrypt will be interpreted as formatted as OpenSSL compatible (Base64) text.

You can encrypt it for example with the OpenSSL functions of PHP 7. Specify the hash iteration count used to generate the key and initialization vector with the optional -HashIterationCount=n switch. Use for example -HashIterationCount=10000.

Note that the default for -OpenSSLCompatible is 1.
You can also decrypt encrypted text created by the openssl command in a command line interface (for example the macOS terminal). Use the switch -OpenSSLCompatible, but don’t use the -HashIterationCount=n switch as the openssl command uses the (default) iteration count of 1.

See the OpenSSL.fmp12 example in the download for more detailed information.

Example

Encr_DecryptAES ( "-Unused" ; "mypassword" ; 
          "<TROI_AES_STD_ENCR10>
          NVFJPSV9fX19fX19fX19fbpsts4SthcI/85T5dcjEv7IsuDGy72Z/t4bfFUyOY7A2ITa3jzEx
          wyy+kHnWsgo/IJ1d7BZeRWA6Wbtzn8/xyAgm47SuJ167SJMLb5k/Kl11dKFuaQ==
          </TROI_AES_STD_ENCR10>" )

This will gives this result:
mySecretTexts

Example 2

In a database you have defined a text field named “encryptedPatientData” which contains encrypted illness data. Then define a calculation field:

patientDataCalc    calculation   Unstored  = Encr_DecryptAES ( "-Unused" ; 
							gPasswordField ; patientData )

the calculation field will contain the decrypted text, but only if the password is correct.

Related functionsFunction badge

Encr_Code
Encr_EncryptAES
Encr_EncryptNewDES

Related topics

Troi Encryptor Plug-in online help (overview)


Online Help Page for Troi Encryptor Plug-in for 14 to 17 –> Encr_DecryptAES (encrp4260) 2019-0212 17:49:27