Syntax
DES_ENCRYPT(str[,{key_num|key_str}])
Purpose
This function is effective only when OceanBase 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 key_num parameter specifies the key number (0 to 9) in the DES key file.
The returned string is a binary string, where the first character is CHAR(128 | key_num). If an error occurs, DES_ENCRYPT() returns NULL. The value 128 is used to make it easier to identify the encryption key. If a string key is used, key_num is 127.
The length of the result string is calculated using the following formula:
new_len = orig_len + (8 - (orig_len % 8)) + 1
Each line in the DES key file is formatted as key_num des_key_str_. Each key_num value must be a number between 0 and 9. The lines in the file can be in any order. des_key_str is the string used for encrypting information. There must be at least one space between the number and the key. If no key parameters are specified for DES_ENCRYPT(), the first key is used as the default key.
Note
OceanBase Database does not currently support editing the DES key file using --des_key_file. Therefore, the keys read by DES_ENCRYPT() and DES_DECRYPT() are the same as the default key file in 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
