Skip to content

Encrypt Filter Function

The encrypt filter plugin for Treasure Data integrations allows you to encrypt columns using an encryption algorithm such as AES.

Options

The encrypt filter plugin contains the following options:

OptionDescription

algorithm

Encryption algorithm (string, required)

Available algorithms are:

  • AES-256-CBC
  • AES-192-CBC
  • AES-128-CBC
  • AES-256-ECB
  • AES-192-ECB
  • AES-128-ECB
column_namesNames of string columns to encrypt (array, required)
key_typeEncryption type, can be either "inline" or "s3" (string, optional, default: inline)
key_hexEncryption key (string, required if key_type is inline)
iv_hexEncryption initialization vector (string, required if mode of the algorithm is CBC and key_type is inline)
output_encodingThe encoding of encrypted value, can be either "base64" or "hex" (string, optional, default: base64)
aws_paramsAWS/S3 parameters (a hash, required if key_type is s3)
Child Elements (aws_params)Description
regiona valid AWS region (string, required)
access_keya valid AWS access key (string, required)
secret_keya valid AWS secret key (string, required)
bucketa valid S3 bucket (string, required)
patha valid S3 key, S3 file path (string, required)

Configuration

Add the filter section, including the type, to your load.yml. In the following example, the type is encrypt:

in:
...
filters:
  - type: encrypt
    algorithm: AES-256-CBC
    column_names: [password, ip]
    key_hex: xxxxxxxxxxxxxxxxxxx
    iv_hex: xxxxxxxxxxx
    output_encoding: hex

out:
...

Advanced Configuration (S3)

Add a filter section, including the type of filter, to your load.yml. In the following example, the type is encrypt and key_type is s3:

in:
...

filters:
  - type: encrypt
    algorithm: AES-256-CBC
    column_names: [password, ip]
    output_encoding: hex
    key_type: s3
    aws_params:
      region: us-east-2
      access_key: XXXXXXXXXXXXXXXXXXXX
      secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      bucket: com.sample.keys
      path: key.aes
out:
...

The S3 key file should be in valid YAML format: (iv_hex is required if mode of the algorithm is CBC)

key_hex: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
key_ivxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx