MySQL ENCODE() function
ENCODE() function
MySQL ENCODE() function encrypts a string. This function returns a binary string of the same length of the original string.
Syntax:
ENCODE(str, pass_str);
Arguments:
Name | Description |
---|---|
str | A string which is to be encrypted. |
pass_str | A string to encrypt str. |
Syntax Diagram:

MySQL Version: 8.0
Example:
Code:
SELECT ENCODE('mytext','mykeystring');
Explanation:
The above MySQL statement will encrypt the string 'mytext' with 'mykeystring'.
Output:
mysql> SELECT ENCODE('mytext','mykeystring'); +--------------------------------+ | ENCODE('mytext','mykeystring') | +--------------------------------+ | ">¿¡È | +--------------------------------+ 1 row in set (0.00 sec)
Example: MySQL encode() function using table
Sample table: testtable
Code:
INSERT INTO testtable VALUE(ENCODE('myencodetext','mypassw'));
Explanation:
The above MySQL statement inserts encrypted data into table 'testtable'.
Output:
mysql> INSERT INTO testtable VALUE(ENCODE('myencodetext','mypassw')); Query OK, 1 row affected (0.00 sec)
Previous: DES_ENCRYPT()
Next: ENCRYPT()
- 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
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook