Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2016
    Posts
    3
    Provided Answers: 1

    Answered: DES_ENCRYPT(str, key_num) didn't work

    hi everyone,
    i try to using DES_ENCRYPT function for encrypting column data in mariadb 5.5 because some feature.
    keys saves in server side. the application engineer didn't know the key.

    Now i enable the SSL. And create a des key file as:

    0 0123456789ABCDEFFEDCBA987654321089ABCDEF01234567
    1 0022446688AACCEEFFDDBB997755331188AACCEE00224466

    and restart the service with --des-key-file=/path/des_key_file.
    But i couldn't use the key to encrypt / decrypt in des key file.

    Following is my experiment process.

    1. create a table

    CREATE TABLE `des_test` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `des_plain` VARCHAR(50) NOT NULL,
    `des_encrpyt_0` VARBINARY(500) DEFAULT NULL,
    `des_encrpyt_1` VARBINARY(500) DEFAULT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=INNODB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

    2. Insert a record
    INSERT INTO `des_test`
    (
    `des_plain`,
    `des_encrpyt_0`,
    `des_encrpyt_1`)
    VALUES (
    'des_plain',
    DES_ENCRYPT('des_plain', 0),
    DES_ENCRYPT('des_plain', 1));

    3. Select data
    SELECT
    `id`,
    `des_plain`,
    DES_DECRYPT(`des_encrpyt_0`, 0),
    DES_DECRYPT(`des_encrpyt_1`, 1)
    FROM `des_test`

    id des_plain DES_DECRYPT(`des_encrpyt_0`, 0) DES_DECRYPT(`des_encrpyt_1`, 1)
    1 des_plain �Q�߭�N���nۆ NULL

    if using the following t-sql
    SELECT
    `id`,
    `des_plain`,
    DES_DECRYPT(`des_encrpyt_0`),
    DES_DECRYPT(`des_encrpyt_1`)
    FROM `des_test`

    id des_plain DES_DECRYPT(`des_encrpyt_0`) DES_DECRYPT(`des_encrpyt_1`)
    1 des_plain des_plain des_plain

    i don't know what's happened with it?
    i just do it with https://mariadb.com/kb/en/mariadb/des_encrypt/.
    could anyone help me?

  2. Best Answer
    Posted by aaron_yang

    "DES_DECRYPT('encrypted_text') -> can't using key_num.
    another one is that encrypt with key_str must be decrypted with key_str.
    and encrypt with key_num decrypt with nothing."


  3. #2
    Join Date
    Mar 2016
    Posts
    3
    Did you try to use FLUSH DES_KEY_FILE statement?
    Maybe Mariadb needs to update its values from the key file

  4. #3
    Join Date
    Feb 2016
    Posts
    3
    Provided Answers: 1

    Lightbulb

    DES_DECRYPT('encrypted_text') -> can't using key_num.
    another one is that encrypt with key_str must be decrypted with key_str.
    and encrypt with key_num decrypt with nothing.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •