Skip to main content
Version: V1.0.0

DES_ENCRYPT

Syntax

DES_ENCRYPT(str[,{key_num|key_str}])

Description

This function is only effective when seekdb 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 in the DES key file (0 to 9).

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 to encrypt the information. There should 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.

info

The current version of seekdb does not support editing the DES key file using --des_key_file, so DES_ENCRYPT() and DES_DECRYPT() currently use the same keys as the default key file in MySQL 8.0.

Examples

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 (0.001 sec)