Skip to main content

Encr_Code (function reference)

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

Encr_Code

Performs an encryption or decryption of the data field, depending on switches.

SyntaxFunction badge

Encr_Code ( switches ; password ; data )

Parameters

switches specify what (de)coding action to perform
password the password to use
data the text (or container) to perform the action on

Switches

Switches can be:

-EncryptDES encrypt using the newDES algorithm (and the password)
-DecryptDES decrypt using the newDES algorithm (and the password)
-EncryptAES encrypt using the (more secure) AES algorithm (and the password)
-DecryptAES decrypt using the (more secure) AES algorithm (and the password)

You can still use these two alternative names for the AES algorithm:

-EncryptRijndaelAES encrypt using the (more secure) AES algorithm (and the password)
-DecryptRijndaelAES decrypt using the (more secure) AES algorithm (and the password)

You can also use

-DecodeSafeAsciiDecryptDESDecompress first decode from SafeAscii, then decryptDES and then decompress

For AES encryption you can also add one or more of these switches to retrieve extra information:

-AddIntializationVectorInfo add the used Intialization Vector at the end of the result (need not be kept secret)
-AddSaltInfo add the used Salt at the end of the result (need not be kept secret)
-AddKeyInfo add the derived Key (derived from the password) at the end of the result (keep secret!)
-OpenSSLCompatible format as OpenSSL compatible result
-HashIterationCount=x specify the hash iteration count used to generate the key and IV (for OpenSSL)

Other switches are not (yet) possible.

Returned Result

Data type returned

Text

Result

the coded text. This can be encrypted text or decrypted text.

Originated in

Troi Encryptor Plug-in 1.5

Compatibility

FileMaker Pro 16 to FileMaker Pro 2023

Considerations

– You can use this function to encrypt and decrypt without a script.
– For good security make sure the password is at least 10 characters long. Also be aware that the password is case sensitive.
– (Rijndael) AES is a more secure algorithm than unsecure NewDES.
See Encr_EncryptAES for more technical information on the AES implementation.

Version 7.0 added the -EncryptAES and -DecryptAES switches. These alternative switch names will encrypt and decrypt the data using the AES algorithm.

Version 2.5.2 added the switch “-DecodeSafeAsciiDecryptDESDecompress”. This will perform three actions in succession: first decode from SafeAscii, then decrypt the intermediate result (using decryptDES) and finally decompress it.

About OpenSSL compatibility (introduced with Troi Encryptor 5.0): see the Encr_EncryptAES and Encr_DecryptAES function for more information.

Example

Set Field [ secretField ;   
		Encr_Code ( "-EncryptDES" ;  gEncryptionPassword ; textField ) ]
Set Field [ result ;   
		Encr_Code ( "-DecryptDES" ;  gDecryptionPassword ;  secretField ) ]

gDecryptionPassword = a global text field where the user can type in the password that will be used to generate a key for the encryption or decryption.

Example 2

Set Field [ secretField ;   
		Encr_Code ( "-EncryptAES -AddSaltInfo" ;  
		gEncryptionPassword ; textField ) ]

this will result in:

<TROI_AES_STD_ENCR10>
NVFJPSV9fX19fX19fX19fbkO656mTvKWiWbKQqul7R5tZd7+aQ3h0QaLQOO6EUtFjxDLRxNQp
rwFN1JhuE5SNPaSBWbCrteX7uPmqKpdyFrmcGwqX7CjZ5cE/ISIwD6LWh3hguv1JObZqj7+n
fWhvu4AflFM765T8hlg6BbeHjI2oUwGz
</TROI_AES_STD_ENCR10>

<TROI_SALT>43bae7a993bca5a259b290aae97b479b5977bf9a</TROI_SALT>

Used in example file

EncryptNewDES.fmp12

Related functionsFunction badge

Encr_DecryptAES
Encr_DecryptNewDES
Encr_EncodeSafeAscii
Encr_EncryptAES
Encr_EncryptNewDES

Related topics

Troi Encryptor Plug-in online help (overview)


Online Help Page for Troi Encryptor Plug-in for 16 to 2023 –> Encr_Code (encrp4221) 2023-0425 15:43:52