Encryption and Compression Functions

TiDB supports most of the encryption and compression functions available in MySQL 8.0.

Supported functions

NameDescription
MD5()Calculate MD5 checksum
PASSWORD()Calculate and return a password string
RANDOMBYTES()Return a random byte vector
SHA1(), SHA()Calculate an SHA-1 160-bit checksum
SHA2()Calculate an SHA-2 checksum
<a href=”https://en.wikipedia.org/wiki/SM3(hash_function)” target=”_blank” referrerpolicy=”no-referrer-when-downgrade”>SM3()Calculate an SM3 checksum (currently MySQL does not support this function)
AES_DECRYPT()Decrypt using AES
AES_ENCRYPT()Encrypt using AES
COMPRESS()Return result as a binary string
UNCOMPRESS()Uncompress a string compressed
UNCOMPRESSED_LENGTH()Return the length of a string before compression
VALIDATE_PASSWORD_STRENGTH()Validate the password strength

The block_encryption_mode variable sets the encryption mode that is used for AES_ENCRYPT() and AES_DECRYPT().

The validate_password.* variables affect the VALIDATE_PASSWORD_STRENGTH() function.

Unsupported functions

  • DES_DECRYPT(), DES_ENCRYPT(), OLD_PASSWORD(), ENCRYPT(): these functions were deprecated in MySQL 5.7 and removed in 8.0.
  • Functions only available in MySQL Enterprise Issue #2632.

MySQL compatibility

  • TiDB does not support the STATEMENT_DIGEST() and STATEMENT_DIGEST_TEXT() functions.