DataScript: avi.crypto.decrypt

Function avi.crypto.decrypt( ciphertext, key [, iv [, algo]] )
Description DataScripts can be used to encrypt and decrypt data. The supported decryption algorithms are AES and 3DES. For AES decryption, AES128, AES192 and AES256 are supported and require key lengths of 128, 192, and 256 bits respectively. 3DES requires key length (3X56) of 168 bits padded out to 192 bits. Whichever decryption method is being used, the correct key length via the key string is mandatory.

Only CBC (cipher block chaining) mode is supported. Default decryption algorithm used is AES256 with the default IV of “0123456789012345” and default mode of CBC.

Parameter ciphertext is the encrypted text or string to be decrypted.
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 decryption algorithm. Choose between:

  • avi.CIPHER_AES
  • avi.CIPHER_3DES
Returns A decrypted string
Example During the HTTP Response event, check for a header then encrypt its value.
if avi.http.get_header("User")
   encrypt = avi.crypto.encrypt(avi.http.get_header("User"), key)
   avi.http.replace_header("User", encrypt)
During the HTTP Request event, check for a header then decrypt its value.
if avi.http.get_header("User")
   decrypt = avi.crypto.decrypt(avi.http.get_header("User"), key)
   avi.http.replace_header("User", decrypt)

Updated: 2018-01-19 07:13:00 +0000