Loading

MySQL Encryption or Compression Functions

In MySQL Encryption or Compression Function, we will discuss the AES_DECRYPT Function, AES_ENCRYPT Function, CRC32 Function, ENCRYPT Function, FROM_BASE64 Function, MD5 Function, OLD_PASSWORD Function, PASSWORD Function.

AES_DECRYPT Function:-  AES_DECRYPT Function is used for decrypting an encrypted string. It uses AES (Advanced Encryption Standard) Algorithm. It returns the original string. In case of invalid data. It returns NULL.

Syntax:- AES_DECRYPT(encrypt_str, key_str)

Example:- SELECT AES_DECRYPT(AES_ENCRYPT(‘xyz456’, ‘key_string’), ‘key_string’);

Output:- xyz456

AES_ENCRYPT Function:- AES_ENCRYPT Function is used for encrypting the string using AES (Advanced Encryption Standard) Algorithm.

Syntax:- AES_ENCRYPT(str, key_str)

Example:- SELECT AES_ENCRYPT(‘xyz456’, ‘key_string’);

Output:- 0xcf742d7a140d469154ecc36fac4b1aaf

CRC32 Function:- CRC32 Function is used to compute a cyclic redundancy check value and return a 32-bit unassigned value. In case of NULL, it returns NULL.

Syntax:- CRC32(exp)

Example:- SELECT CRC32(“kshtutor”);

Output:- 2392954192

ENCRYPT Function:- ENCRYPT Function is used for encrypting strings using a UNIX crypt() system call. In the case of the window system, It will return NULL.

Syntax:- ENCRYPT(str, salt)

Example:-

SELECT ENCRYPT(‘kshtutor’, ‘decode’);

FROM_BASE64 Function:- FROM_BASE64 Function is used to decode base64 string.

Syntax:- FROM_BASE64(str)

Example:- SELECT FROM_BASE64(‘F2Q0’)

Output:- 0x176434

MD5 Function:- MD5 Function is used to calculate 128-bit MD5 checksum string. It returns 32-bit hexadecimal digits.

Syntax:- MD5(string)

Example:- SELECT MD5(‘kshtutor’)

Output:- 02fb107e31fe5a92b249ab4944ca0299

OLD_PASSWORD Function:- OLD_PASSWORD Function is used for the authentication system to generate hashed passwords from a plain text password string. It returns a 16-byte format binary string.

Syntax:- OLD_PASSWORD(str)

Example:- SELECT OLD_PASSWORD(‘ksh’);

PASSWORD Function:- The PASSWORD Function is used for returning binary strings from plain text passwords. It uses a hashing technique for generating a password. In case of NULL, It returns a NULL value.

Syntax:- PASSWORD(str)

Example:- SELECT PASSWORD(‘ksh’);

Output:- FD0602804190D276DBFFF18ED39204C1E3E53BED

Read Also:-

MySQL Functions
MySQL String Functions
MySQL Numeric or Mathematical Function
MySQL Date Or Time Function
MySQL Advanced Function
MySQL Encryption or Compression Function

Please read more detail about MySQL Encryption or Compression Functions in the MySQL manual

 

One thought on “MySQL Encryption or Compression Functions

Leave a Reply

z35W7z4v9z8w
Verified by ExactMetrics