MariaDB: ENCRYPT Function
This MariaDB tutorial explains how to use the MariaDB ENCRYPT function with syntax and examples.
Description
The MariaDB ENCRYPT function is used to encrypt a string using UNIX crypt().
Syntax
The syntax for the ENCRYPT function in MariaDB is:
ENCRYPT( string [, salt ] )
Parameters or Arguments
- string
- A plaintext string that is encrypted using UNIX crypt().
- salt
- Optional. It is a string that is at least 2 characters long that is used in the encryption process. If salt is not provided, the ENCRYPT function will use a random value.
Note
- The ENCRYPT function will return NULL, if salt is less than 2 characters in length.
- The ENCRYPT function will return NULL, if the string is NULL.
Applies To
The ENCRYPT function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB ENCRYPT function examples and explore how to use the ENCRYPT function in MariaDB.
For example:
SELECT ENCRYPT('TechOnTheNet.com'); Result: 'A8h9CE6m4Ljm2' SELECT ENCRYPT('TechOnTheNet.com', '12'); Result: '12mNyZnOmGco6' SELECT ENCRYPT('TechOnTheNet.com', '1'); Result: NULL SELECT ENCRYPT(NULL); Result: NULL
Advertisements