ENCRYPT(string[,salt])

Description: Encrypts string using the Unix crypt() function, returning the encrypted result.

If salt is omitted, a random salt is used, so that the result is different every time. If salt is specified, the result of encrypting string will always be the same with that salt.

On systems without crypt() available, ENCRYPT() returns NULL. On most systems, only the first eight characters of string are used for encryption; the rest are ignored.

Examples:

  • ENCRYPT('My secret message') returns FOXv7kZdrHGkw.

  • ENCRYPT('My secret message','xx') returns xxgNrzQDHDL/g.

See also: AES_ENCRYPT(), ENCODE(), MD5(), PASSWORD()

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.