« xDev Magazine Issue 1… | Home | Save the dates »

AES in FileMaker and PHP

You may have seen the AES blog post recently for AES encryption in both PHP and Xojo (Real Studio). The same AES encryption works in FileMaker, too.

Here is the example script:

# prepare

Set Variable [$keyHash; Value:MBS( "Hash.Digest"; "SHA256"; "Text"; AES like PHP::keyPlainText; "UTF-8"; "hex")]

Set Field [AES like PHP::keyHash; $keyHash]

Set Variable [$IVHash; Value:MBS( "Hash.Digest"; "SHA256"; "Text";AES like PHP::ivPlainText; "UTF-8"; "hex")]

Set Variable [$IVHash; Value:Left($IVHash; 32)]

Set Field [AES like PHP::IV; $IVHash]

# encrypt

Set Field [AES like PHP::EncryptedData; MBS( "Encryption.Cipher"; "encrypt"; AES like PHP::algorithm; "hex"; AES like PHP::keyHash; ""; "text"; AES like PHP::dataPlaintext; "UTF-8"; "base64"; ""; "hex"; AES like PHP::IV )]

# decrypt

Set Field [AES like PHP::DecryptedData; MBS( "Encryption.Cipher"; "decrypt"; AES like PHP::algorithm; "hex"; AES like PHP::keyHash; ""; "base64"; AES like PHP::EncryptedData; ""; "text"; "UTF-8"; "hex"; AES like PHP::IV; "" )] 

07 01 16 - 11:06