数据加密

语法说明

  1. CREATE ENCRYPT RULE encryptRuleDefinition [, encryptRuleDefinition] ...
  2. ALTER ENCRYPT RULE encryptRuleDefinition [, encryptRuleDefinition] ...
  3. DROP ENCRYPT RULE tableName [, tableName] ...
  4. encryptRuleDefinition:
  5. tableName(COLUMNS(columnDefinition [, columnDefinition] ...), QUERY_WITH_CIPHER_COLUMN=queryWithCipherColumn)
  6. columnDefinition:
  7. (NAME=columnName [, PLAIN=plainColumnName] , CIPHER=cipherColumnName, encryptAlgorithm)
  8. encryptAlgorithm:
  9. TYPE(NAME=encryptAlgorithmType [, PROPERTIES([algorithmProperties] )] )
  10. algorithmProperties:
  11. algorithmProperty [, algorithmProperty] ...
  12. algorithmProperty:
  13. key=value
  • PLAIN 指定明文数据列,CIPHER 指定密文数据列
  • encryptAlgorithmType 指定加密算法类型,请参考 加密算法
  • 重复的 tableName 将无法被创建
  • queryWithCipherColumn 支持大写或小写的 true 或 false

示例

  1. CREATE ENCRYPT RULE t_encrypt (
  2. COLUMNS(
  3. (NAME=user_id,PLAIN=user_plain,CIPHER=user_cipher,TYPE(NAME=AES,PROPERTIES('aes-key-value'='123456abc'))),
  4. (NAME=order_id, CIPHER =order_cipher,TYPE(NAME=MD5))
  5. ),QUERY_WITH_CIPHER_COLUMN=true),
  6. t_encrypt_2 (
  7. COLUMNS(
  8. (NAME=user_id,PLAIN=user_plain,CIPHER=user_cipher,TYPE(NAME=AES,PROPERTIES('aes-key-value'='123456abc'))),
  9. (NAME=order_id, CIPHER=order_cipher,TYPE(NAME=MD5))
  10. ), QUERY_WITH_CIPHER_COLUMN=FALSE);
  11. ALTER ENCRYPT RULE t_encrypt (
  12. COLUMNS(
  13. (NAME=user_id,PLAIN=user_plain,CIPHER=user_cipher,TYPE(NAME=AES,PROPERTIES('aes-key-value'='123456abc'))),
  14. (NAME=order_id,CIPHER=order_cipher,TYPE(NAME=MD5))
  15. ), QUERY_WITH_CIPHER_COLUMN=TRUE);
  16. DROP ENCRYPT RULE t_encrypt,t_encrypt_2;