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 Version: 8.0
Example:
Code:
SELECT ENCRYPT('w3resource', 'encode');
Explanation
The above MySQL statement encrypts w3resource with encoding.
Output:
mysql> SELECT ENCRYPT('w3resource', 'encode'); +---------------------------------+ | ENCRYPT('w3resource', 'encode') | +---------------------------------+ | NULL | +---------------------------------+ 1 row in set (0.00 sec)
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join