Jump to: navigation, search

Mysql DES DECRYPT

From w3cyberlearnings

Contents

MySQL DES_DECRYPT Function

This function decrypts the encrypted string that used DES_ENCRYPT().

Syntax DES_DECRYPT

  • encrypted string
  • key_str: key used for encrypted the encrypted string.
DES_DECRYPT(encrypted string, key_str);

Example 1

mysql> SET @tt=DES_ENCRYPT('w3cyberlearnings.com','gg');
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @tt;
+---------------------------+
| @tt                       |
+---------------------------+
| ���}�$�:
u4D#+&oto������� | 
+---------------------------+
1 row in set (0.00 sec)

mysql> SELECT DES_DECRYPT(@tt,'gg');
+-----------------------+
| DES_DECRYPT(@tt,'gg') |
+-----------------------+
| w3cyberlearnings.com  | 
+-----------------------+
1 row in set (0.00 sec)

mysql> SELECT DES_DECRYPT(@tt,'gg3');
+------------------------+
| DES_DECRYPT(@tt,'gg3') |
+------------------------+
| NULL                   | 
+------------------------+
1 row in set (0.00 sec)

Example 2

mysql> INSERT INTO userpassword(username, password)
    -> VALUES('Koka',DES_ENCRYPT('great','ag'));
Query OK, 1 row affected (0.00 sec)

mysql> SELECT username, DES_DECRYPT(password,'ag') 
    -> FROM userpassword;
+----------+----------------------------+
| username | DES_DECRYPT(password,'ag') |
+----------+----------------------------+
| Koka     | great                      | 
+----------+----------------------------+
1 row in set (0.00 sec)


Related Links


Navigation
Web
SQL
MISC
References