Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL ENCRYPT() function

ENCRYPT() function

MySQL ENCRYPT() encrypts a string using the Unix crypt() system call. The function returns a binary string.

Since the function is based on Unix crypt() system call, on Windows systems, it will return NULL.

Syntax:

ENCRYPT(string, salt)

Arguments

Name Description
string A string which is to be encrypted.
salt A string with at least two characters. If salt is less than two characters, the function will return NULL. If this argument is not set, the function uses a random value for encryption.

Syntax Diagram:

MySQL ENCRYPT() Function - Syntax Diagram

MySQL Version: 5.6


Example:

Code:

SELECT ENCRYPT('w3resource', 'encode');

Explanation

The above MySQL statement encrypts w3resource with encoding.

Sample Output:

mysql> SELECT ENCRYPT('w3resource', 'encode');
+---------------------------------+
| ENCRYPT('w3resource', 'encode') |
+---------------------------------+
| NULL                            | 
+---------------------------------+
1 row in set (0.00 sec)

Previous: ENCODE()
Next: MD5()