Encryption and hash functions
MD5, SHA1 and SHA2: the hash functions Raft DB has, and the encryption functions it does not have.
Raft DB implements the checksum functions below. They take the bytes of the text and return text.
Not supported yet: AES_ENCRYPT, AES_DECRYPT, COMPRESS, UNCOMPRESS, UNCOMPRESSED_LENGTH, RANDOM_BYTES, PASSWORD, ENCRYPT, ENCODE, DECODE, DES_ENCRYPT, DES_DECRYPT, CRC32C and the key-derivation functions. CRC32 is on Numeric functions; TO_BASE64 and FROM_BASE64 on String functions.
Account passwords are not hashed with these functions; see the chapter on security.
Summary of functions#
| Function | What it does | Dialect |
|---|---|---|
MD5 | Returns the MD5 checksum of str as 32 hexadecimal digits in lower case. | MySQL and MariaDB |
SHA | Synonym of SHA1. | MySQL and MariaDB |
SHA1 | Returns the SHA-1 checksum of str as 40 hexadecimal digits. | MySQL and MariaDB |
SHA2 | Returns the SHA-2 checksum of str. | MySQL and MariaDB |
MD5#
MD5(str)Returns the MD5 checksum of str as 32 hexadecimal digits in lower case.
Example:
SELECT MD5('abc');Result: 900150983cd24fb0d6963f7d28e17f72
SHA#
SHA(str)Synonym of SHA1.
Example:
SELECT SHA('abc');Result: a9993e364706816aba3e25717850c26c9cd0d89d
SHA1#
SHA1(str)Returns the SHA-1 checksum of str as 40 hexadecimal digits.
Example:
SELECT SHA1('abc');Result: a9993e364706816aba3e25717850c26c9cd0d89d
SHA2#
SHA2(str, hash_length)Returns the SHA-2 checksum of str. Only the length 256 (and 0, the same) is supported; other lengths (224, 384, 512) give NULL.
Example:
SELECT SHA2('abc', 256);Result: ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad