©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

MariaDB ENCODE SQL Function - Encrypt with password

ENCODESyntax:ENCODE(String, Password)
Return value:BINARY
Function type:Encryption & Compression
Function Description

The ENCODE() function encrypts "String" with "Password".

The result is a binary string with the same length as "String".

The strength of the encryption depends on the quality of the random number generator.

Numeric values ​​in the "String" and "Password" arguments are interpreted as a character string.

If "String" contains no characters, an empty string is returned.

If the value of the "String" or "Password" argument is NULL, the ENCODE() function returns NULL.


To decode the result, the DECODE() function can be chosen.


This feature is not present in MySQL 8.0.

SQL Examples for the ENCODE function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

select hex(encode('Test''Password'));
select hex(encode(123456, 'Password'));
select hex(encode(123456, 789));

select encode('''Password');
select hex(encode('Test'''));
select encode(null'Password');
select encode('Test'null);

hex(encode('Test', 'Password'))
varchar(8) BINARY
15C81E87
hex(encode(123456, 'Password'))
varchar(12) BINARY
D5E8E316C9D9
hex(encode(123456, 789))
varchar(12) BINARY
D357DDEAA0E3
encode('', 'Password')
varchar(0) BINARY
 
hex(encode('Test', ''))
varchar(8) BINARY
BE26F8C1
encode(null, 'Password')
varchar(0) BINARY
NULL
encode('Test', null)
varchar(4) BINARY
NULL
The examples were created with the MyWAY SQL manager: Download

How to use the ENCODE() function in MySQL and MariaDB databases

MariaDB includes the ENCODE() function that can be used to encode a string with a given password. The ENCODE() function in MariaDB is used to encode strings. The result is returned as a binary string and can be decoded again with the DECODE() function.
DES_DECRYPTDES_ENCRYPTELTENCODEENCRYPTEXPEXPORT_SET

Further MySQL und MariaDB SQL Encryption & Compression

AES_DECRYPTAES_DECRYPT(String, Key)
More about AES_DECRYPT Function

AES_ENCRYPTAES_ENCRYPT(String, Key)
More about AES_ENCRYPT Function

COMPRESSCOMPRESS(String)
More about COMPRESS Function

DECODEDECODE(Binary string, Password)
More about DECODE Function

DES_DECRYPTDES_DECRYPT(Binary string [, Key])
More about DES_DECRYPT Function

DES_ENCRYPTDES_ENCRYPT(String [, Key])
More about DES_ENCRYPT Function

ENCRYPTENCRYPT(String [, Salt])
More about ENCRYPT Function

FROM_BASE64FROM_BASE64(String)
More about FROM_BASE64 Function

MD5MD5(String)
More about MD5 Function

OLD_PASSWORDOLD_PASSWORD(String)
More about OLD_PASSWORD Function

PASSWORDPASSWORD(String)
More about PASSWORD Function

RANDOM_BYTESRANDOM_BYTES(Length)
More about RANDOM_BYTES Function

SHASHA(String)
More about SHA Function

SHA1SHA1(String)
More about SHA1 Function

SHA2SHA2(String, Length)
More about SHA2 Function

TO_BASE64TO_BASE64(String)
More about TO_BASE64 Function

UNCOMPRESSUNCOMPRESS(Binary string)
More about UNCOMPRESS Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the ENCODE SQL function: mariadb.com
Updated: 2023-09-17ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer