# Encryptフィルター関数

Treasure Data統合用のencryptフィルタープラグインを使用すると、AESなどの暗号化アルゴリズムを使用してカラムを暗号化できます。

* [オプション](/ja/products/customer-data-platform/integration-hub/batch/import/filter/encrypt-filter-function#options)
* [設定](/ja/products/customer-data-platform/integration-hub/batch/import/filter/encrypt-filter-function#configuration)
* [高度な設定（S3）](/ja/products/customer-data-platform/integration-hub/batch/import/filter/encrypt-filter-function#advanced-configuration-s3)


## オプション

encryptフィルタープラグインには以下のオプションがあります：

| オプション | 説明 |
|  --- | --- |
| algorithm
 | 暗号化アルゴリズム（string、必須）
利用可能なアルゴリズム：
- AES-256-CBC
- AES-192-CBC
- AES-128-CBC
- AES-256-ECB
- AES-192-ECB
- AES-128-ECB

 |
| column_names | 暗号化する文字列カラムの名前（array、必須） |
| key_type | 暗号化タイプ、「inline」または「s3」のいずれか（string、オプション、デフォルト：inline） |
| key_hex | 暗号化キー（string、key_typeがinlineの場合は必須） |
| iv_hex | 暗号化初期化ベクトル（string、アルゴリズムのモードがCBCでkey_typeがinlineの場合は必須） |
| output_encoding | 暗号化された値のエンコーディング、「base64」または「hex」のいずれか（string、オプション、デフォルト：base64） |
| aws_params | AWS/S3パラメータ（hash、key_typeがs3の場合は必須） |


| 子要素（aws_params） | 説明 |
|  --- | --- |
| region | 有効なAWSリージョン（string、必須） |
| access_key | 有効なAWSアクセスキー（string、必須） |
| secret_key | 有効なAWSシークレットキー（string、必須） |
| bucket | 有効なS3バケット（string、必須） |
| path | 有効なS3キー、S3ファイルパス（string、必須） |


## 設定

`load.yml`にタイプを含む`filter`セクションを追加します。以下の例では、タイプはencryptです：

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

out:
...
```

## 高度な設定（S3）

`load.yml`にフィルターのタイプを含む`filter`セクションを追加します。以下の例では、タイプはencryptでkey_typeはs3です：

```yaml
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:
...
```

S3キーファイルは有効なYAML形式である必要があります：（アルゴリズムのモードがCBCの場合、iv_hexは必須）

```yaml
key_hex: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
key_iv: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```