MySQL DES_DECRYPT() function
DES_DECRYPT() function
MySQL DES_DECRYPT() function decrypts an encrypted string and returns the original string.
Syntax:
DES_DECRYPT(crypt_str, [key_str]);
Arguments:
Name | Description |
---|---|
crypt_str | An encrypted string. |
key_str | String to decrypt crypt_str. |
Syntax Diagram:
MySQL Version: 8.0
Example:
Code:
SELECT DES_DECRYPT(DES_ENCRYPT('mytext','mypassward'),'mypassward');
Explanation:
The above MySQL statement decrypts the encrypted string 'mytext' as specified in the argument and returns the original string.
Output:
mysql> SELECT DES_DECRYPT(DES_ENCRYPT('mytext','mypassward'),'mypassward'); +--------------------------------------------------------------+ | DES_DECRYPT(DES_ENCRYPT('mytext','mypassward'),'mypassward') | +--------------------------------------------------------------+ | mytext | +--------------------------------------------------------------+ 1 row in set (0.01 sec)
Example of MySQL des_decrypt() function using table
Sample table: testtable
Code:
SELECT description,DES_DECRYPT(description,'mydespassw')
FROM testtable;
Explanation:
The above MySQL statement retrieves the decrypted data from encrypted 'description' column from 'testtable'.
Output:
Previous: DECODE()
Next: DES_ENCRYPT()
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/mysql/encryption-and-compression-functions/des_decrypt().php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics