|avi.crypto.encrypt( plaintext, key [, iv [, algo]] )
|DataScript has the ability to encrypt arbitrary data. This can be useful for encrypting server cookie values or creating custom cross site scripting mitigation by embedding validation tokens. The supported encryption algorithms are AES and 3DES.
For AES encryption, AES128, AES192 and AES256 are supported and require key lengths of 128, 192, and 256 bits respectively. 3DES requires a key length (3X56) of 168 bits padded out to 192 bits. Regardless which encryption algorithm is used, the corresponding correct key length via the key string is mandatory.
Only CBC (cipher block chaining) mode is supported. The default encryption algorithm used is AES256, with the default IV value of “0123456789012345” and default mode of CBC.
|plaintext is the text or string to be encrypted.
key is a string, which is the private key to use for the encryption.
iv is a string and is the initialization vector.
algo is the encryption algorithm cipher. Choose between:
|An encrypted string
|Send an encrypted token, using AES256 in CBC mode with default IV, in a header in the HTTP response.