ENCRYPT()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Encrypts a string with the Unix crypt()
system call.
USAGE
ENCRYPT(string[, salt])
Argument Name | Description |
---|---|
| The string to encrypt |
| Optional. The salt to use for the crypt() call |
DETAILS
ENCRYPT()
is an encryption function that returns the UNIX crypt() encoding of a string.
If the optional 2-character salt
argument is not provided, a random salt value will be used. If more than 2 characters are specified for the salt, the first 2 characters are used.
A NULL
is returned if either argument is NULL
or if the salt
is fewer than 2 characters.
EXAMPLES
SELECT ENCRYPT('secret', 'xy');
+-------------------------+
| ENCRYPT('secret', 'xy') |
+-------------------------+
| xy/gRonXQz8UE |
+-------------------------+
SELECT ENCRYPT('secret', 'x');
+------------------------+
| ENCRYPT('secret', 'x') |
+------------------------+
| NULL |
+------------------------+