Skip to main content
Version: V1.0.0

ENCRYPT

Syntax

ENCRYPT(str[,salt])

Description

ENCRYPT() uses the Unix crypt() call to encrypt str and returns a binary string. The salt parameter must be a string of at least two characters; otherwise, the result is NULL. If you do not specify the salt parameter, a random value is used.

Because the system call requires a string that is null-terminated, we recommend that you do not use ENCRYPT() with the ucs2, utf16, utf16le, or utf32 multibyte character sets.

If the system does not support crypt(), ENCRYPT() always returns NULL.

Examples

SELECT ENCRYPT('hello');
+------------------+
| ENCRYPT('hello') |
+------------------+
| XROflfjMAx1GA |
+------------------+
1 row in set (0.001 sec)