Logo
Data Encryption

Data Encryption #

Configuration Details #

Version 1.5.0 introduced adjustments to encryption API configurations, making it convenient to use while also maintaining compatibility with the old API configurations.

New API Configurations after Version 1.5.0 #

rules:
- !ENCRYPT
  tables:
    <table-name> (+): # Encrypted table name
      columns:
        <column-name> (+): # Encrypted column name
          dataType: # Logical column type
          plain: # Plain text configuration
            name: # Plain text column name
            dataType: # Plain text column data type length
          cipher: # Cipher text configuration
            name: # Cipher text column name
            dataType: # Cipher text column data type length
            encryptorName: # Encryption algorithm name
          assistedQuery: # Query assistance column configuration
            name: # Query assistance column name
            dataType: # Query assistance column data type length
            encryptorName: # Query assistance algorithm
          likeQuery: # Fuzzy query column configuration
            name: # Fuzzy query column name
            dataType: # Fuzzy query column data type length
            encryptorName: # Fuzzy query algorithm
          queryWithCipherColumn: true # Use cipher columns for column-level configuration
        queryWithCipherColumn: true # Use cipher columns for table-level configuration
      queryWithCipherColumn: true # Use cipher columns for rule-level configuration

  # Encryption algorithm configuration
  encryptors:
    <encrypt-algorithm-name> (+): # Encryption and decryption algorithm name
      type: # Encryption and decryption algorithm type
      props: # Encryption and decryption algorithm property configuration
        # ...

  queryWithCipherColumn: # Whether to use encrypted columns for queries. In the presence of plain text columns, plain text columns can be used for queries.

  # Key storage management configuration
  keyManagers:
    <key-manager-name> (+): # Key storage manager name
      type: # Key storage manager type, supports Local storage, AWS cloud storage
      props: # Key storage manager property configuration
        # ...
  • Example
rules:
- !ENCRYPT
  encryptors:
    aes_encryptor:
      type: AES
      props:
        aes-key-value: 123456abc
    char_digest_like_encryptor:
      type: CHAR_DIGEST_LIKE
      props:
        delta: 2
    md5_assisted_encryptor:
      type: MD5
      props:
        salt: 121212
  
  tables:
    t_merchant:
      columns:
        merchant_name:
          dataType: varchar(20)
          plain:
            name: merchant_name_plain
            dataType: varchar(20)
          cipher:
            name: merchant_name_cipher
            dataType: varchar(100)
            encryptorName: aes_encryptor
          assistedQuery:
            name: merchant_name_assisted
            dataType: varchar(100)
            encryptorName: md5_assisted_encryptor
          likeQuery:
            name: merchant_name_like
            dataType: varchar(50)
            encryptorName: char_digest_like_encryptor
          queryWithCipherColumn: true
      queryWithCipherColumn: true
  queryWithCipherColumn: true

Compatibility with Old API Configurations after Version 1.5.0 #

rules:
- !COMPATIBLE_ENCRYPT
  tables:
    <table-name> (+): # 加密表名称
      columns:
        <column-name> (+): # 加密列名称
          dataType: # 逻辑列类型
          cipherColumn: # 密文列名称
          cipherDataType: # 加密列类型
          assistedQueryColumn (?):  # 查询辅助列名称
          assistedQueryDataType: # 查询辅助列类型
          plainColumn (?): # 原文列名称
          plainDataType: # 原文列类型
          encryptorName: # 加密算法名称
      queryWithCipherColumn(?): # 该表是否使用加密列进行查询
    
  # 加密算法配置
  encryptors:
    <encrypt-algorithm-name> (+): # 加解密算法名称
      type: # 加解密算法类型
      props: # 加解密算法属性配置
        # ...

  queryWithCipherColumn: # 是否使用加密列进行查询。在有原文列的情况下,可以使用原文列进行查询

  # 密钥存储管理配置
  keyManagers:
      <key-manager-name> (+): # 密钥存储管理器名称
        type: # 密钥存储管理器类型,支持 Local 存储,AWS 云端存储
        props: # 密钥存储管理器属性配置
          # ...
  • Example

rules:
- !COMPATIBLE_ENCRYPT
  encryptors:
    aes_encryptor:
      type: AES
      props:
        aes-key-value: 123456abc
    char_digest_like_encryptor:
      type: CHAR_DIGEST_LIKE
      props:
        delta: 2
    md5_assisted_encryptor:
      type: MD5
      props:
        salt: 123456
  
  tables:
    t_merchant:
      columns:
        merchant_name:
          dataType: varchar(20)
          plainColumn: merchant_name_plain
          plainDataType: varchar(20)
          cipherColumn: merchant_name_cipher
          cipherDataType: varchar(100)
          encryptorName: aes_encryptor
          assistedQueryColumn: merchant_name_assisted
          assistedQueryDataType: varchar(100)
          assistedQueryEncryptorName: md5_assisted_encryptor
          likeQueryColumn: merchant_name_like
          likeQueryDataType: varchar(50)
          likeQueryEncryptorName: char_digest_like_encryptor
          queryWithCipherColumn: true
      queryWithCipherColumn: true
  queryWithCipherColumn: true