The ENCRYPT() function encrypts the first 8 characters of a "String" using the Unix system call crypt() and returns an encrypted binary string.
The optional argument "Salt" should be at least two characters long, otherwise the function returns NULL.
If "Salt" is not specified, a random value is used depending on the time.
ENCRYPT() should not be used with utf16, utf32 or ucs2 multibyte character sets, since crypt() is a string with a null byte at the end expected.
"String" is truncated after 8 characters when encrypted.
If the have_crypt system variable is not enabled, the ENCRYPT() function always returns NULL.
On Windows, the function always returns NULL because UNIX feature crypt() does not exist and have_crypt cannot be enabled.
Numeric values in the "String" and "Salt" arguments are interpreted as a character string.
If "String" contains no characters, an empty string is returned.
If the value of the "String" or "Salt" argument is NULL, the ENCRYPT() function returns NULL.
This feature is not present in MySQL 8.0. |