encrypt(
DATA
,
PASSWORD
)

The encrypt( function encrypts data.


Parameters

This function has two parameters:

data – the data to be encrypted. This parameter should contain binary data, however, if text is passed, it will automatically be converted to binary data for you (see Binary Data).

password – the password to be used to encrypt the data. You’ll need this password to later decrypt the data.


Description

This function encrypts binary data (or text). The resulting encrypted data is a Binary Data value.

This example encrypts the information in the Letter field (or variable) into a file named Letter.secret, using the password My Secret. (Of course you usually would not want to use a fixed password like this.)

filesave "Letter.secret",encrypt(Letter,"My Secret")

Later, when you want to decode the secret letter, you would use decrypt( function like this:

Letter = decrypt(fileload("Letter.secret"),"My Secret")

If the password used for decrypting doesn’t match the password used for encrypting, an error occurs.

Files on the disk are allowed to contain arbitrary binary data, so the examples above are fine. If you need a text value rather than a binary value, the encodebase64( function is usually the best way to accomplish this. For example, this formula would produce a result that could be sent via an email.

Email = encodebase64(encrypt(Letter,"My Secret"))

To decrypt, use the decodebase64( function.

Letter = decrypt(decodebase64(Email),"My Secret")

Note: This function encrypts data using AES-256 encryption. See Advanced Encryption Standard for more information.


See Also


History

VersionStatusNotes
10.0NewNew in this version.