Encrypt

Syntax

  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 [, ASSISTED_QUERY_COLUMN=assistedQueryColumnName] [, LIKE_QUERY_COLUMN=likeQueryColumnName], encryptAlgorithm [, assistedQueryAlgorithm] [, likeQueryAlgorithm])
  8. encryptAlgorithm:
  9. ENCRYPT_ALGORITHM(TYPE(NAME=encryptAlgorithmType [, PROPERTIES([algorithmProperties] )] ))
  10. assistedQueryAlgorithm
  11. ASSISTED_QUERY_ALGORITHM(TYPE(NAME=encryptAlgorithmType [, PROPERTIES([algorithmProperties] )] ))
  12. likeQueryAlgorithm
  13. LIKE_QUERY_ALGORITHM(TYPE(NAME=encryptAlgorithmType [, PROPERTIES([algorithmProperties] )] ))
  14. algorithmProperties:
  15. algorithmProperty [, algorithmProperty] ...
  16. algorithmProperty:
  17. key=value

Parameters Explained

nameDateTypeDescription
tableNameIDENTIFIERTable name
columnNameIDENTIFIERLogic column name
plainColumnNameIDENTIFIERPlain column name
cipherColumnNameIDENTIFIERCipher column name
assistedQueryColumnNameIDENTIFIERAssisted query column name
likeQueryColumnNameIDENTIFIERLike query column name
encryptAlgorithmTypeSTRINGEncryption algorithm type name

Notes

  • PLAIN specifies the plain column, CIPHER specifies the cipher column
  • encryptAlgorithmType specifies the encryption algorithm type, please refer to Encryption Algorithm
  • Duplicate tableName will not be created
  • queryWithCipherColumn support uppercase or lowercase true or false

Example

  1. CREATE ENCRYPT RULE t_encrypt (
  2. COLUMNS(
  3. (NAME=user_id,PLAIN=user_plain,CIPHER=user_cipher,ASSISTED_QUERY_COLUMN=user_assisted,LIKE_QUERY_COLUMN=user_like,ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456abc'))),ASSISTED_QUERY_ALGORITHM(TYPE(NAME='MD5')), LIKE_QUERY_ALGORITHM(TYPE(NAME='CHAR_DIGEST_LIKE'))),
  4. (NAME=order_id, CIPHER =order_cipher, ENCRYPT_ALGORITHM(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, ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456abc')))),
  9. (NAME=order_id, CIPHER=order_cipher,ENCRYPT_ALGORITHM(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,ASSISTED_QUERY_COLUMN=user_assisted,LIKE_QUERY_COLUMN=user_like,ENCRYPT_ALGORITHM(TYPE(NAME='AES',PROPERTIES('aes-key-value'='123456'))),ASSISTED_QUERY_ALGORITHM(TYPE(NAME='MD5')), LIKE_QUERY_ALGORITHM(TYPE(NAME='CHAR_DIGEST_LIKE'))),
  14. (NAME=order_id,CIPHER=order_cipher,ENCRYPT_ALGORITHM(TYPE(NAME='MD5')))
  15. ), QUERY_WITH_CIPHER_COLUMN=TRUE);
  16. DROP ENCRYPT RULE t_encrypt,t_encrypt_2;