Declaration
DES_ENCRYPT(str[,{key_num|key_str}])
Description
This feature is only effective when OceanBase AI Database is configured to support SSL.
The key_str parameter is used to pass the encryption key for encrypting str. If this parameter is not specified, the first key in the DES key file is used. The value of the key_num parameter is the key number (0 to 9) in the DES key file.
The returned string is a binary string, with the first character being CHAR(128 | key_num). If an error occurs, DES_ENCRYPT() returns NULL. The value 128 is used to make the encryption key easier to identify. If a string key is used, key_num is 127.
The length of a string in the result is calculated using the following formula:
new_len = orig_len + (8 - (orig_len % 8)) + 1
Each line in the DES key file is in the format key_num des_key_str_. Each key_num value must be a digit within the range of 0 to 9. Lines in the file can be arranged in any order. des_key_str is the string used to encrypt information. There must be at least one space between the number and the key. If you do not specify any key parameter for DES_ENCRYPT(), the first key is used as the default key.
Note
The current version of OceanBase AI Database does not support editing the DES key file using --des_key_file. Therefore, the keys read from the key file by DES_ENCRYPT() and DES_DECRYPT() are the same as those in the default key file of MySQL 8.0.
Examples
obclient [test]> SELECT DES_ENCRYPT('text', CONCAT('ob_random_salt','ob_secret_password'));
+--------------------------------------------------------------------+
| DES_ENCRYPT('text', CONCAT('ob_random_salt','ob_secret_password')) |
+--------------------------------------------------------------------+
| ]UA |
+--------------------------------------------------------------------+
1 row in set