Encryption Algorithm

Background

Encryption algorithms are by the encryption features of Apache ShardingSphere. A variety of algorithms are built-in to make it easy for users to fully leverage the feature.

Parameters

Standard Encrypt Algorithm

MD5 Encrypt Algorithm

Type: MD5

Attributes: None

AES Encrypt Algorithm

Type: AES

Attributes:

NameDataTypeDescription
aes-key-valueStringAES KEY

RC4 Encrypt Algorithm

Type: RC4

Attributes:

NameDataTypeDescription
rc4-key-valueStringRC4 KEY

SM3 Encrypt Algorithm

Type: SM3

Attributes:

NameDataTypeDescription
sm3-saltStringSM3 SALT (should be blank or 8 bytes long)

SM4 Encrypt Algorithm

Type: SM4

Attributes:

NameDataTypeDescription
sm4-keyStringSM4 KEY (should be 16 bytes)
sm4-modeStringSM4 MODE (should be CBC or ECB)
sm4-ivStringSM4 IV (should be specified on CBC, 16 bytes long)
sm4-paddingStringSM4 PADDING (should be PKCS5Padding or PKCS7Padding, NoPadding excepted)

Like Encrypt Algorithm

CharDigestLike Encrypt Algorithm

Type:CHAR_DIGEST_LIKE

Attributes:

NameDataTypeDescription
deltaintCharacter Unicode offset(decimal number)
maskintCharacter encryption mask(decimal number)
startintCiphertext Unicode initial code(decimal number)
dictStringCommon words

Operating Procedure

  1. Configure encryptors in an encryption rule.
  2. Use relevant algorithm types in encryptors.

Configuration Examples

  1. rules:
  2. - !ENCRYPT
  3. tables:
  4. t_user:
  5. columns:
  6. username:
  7. plainColumn: username_plain
  8. cipherColumn: username
  9. encryptorName: name_encryptor
  10. likeQueryColumn: name_like
  11. likeQueryEncryptorName: like_encryptor
  12. encryptors:
  13. like_encryptor:
  14. type: CHAR_DIGEST_LIKE
  15. name_encryptor:
  16. type: AES
  17. props:
  18. aes-key-value: 123456abc