Encryption, Encoding, and Checksum Functions

MySQL has a number of commands for creating encrypted and encoded versions of an expression. Here are the commands with their syntax:

  • PASSWORD(string) (returns encrypted form of a password)

  • ENCRYPT(string [,salt]) (encrypts a string)

  • ENCODE(string, password) (encodes a string)

  • DECODE(string, password) (decodes an encoded string)

  • MD5(string) (returns MD5 checksum)

The PASSWORD() function encrypts a string and returns the encrypted result using MySQL's own encryption algorithm. The Password column of MySQL's user authentication table mysql.user contains passwords in the MySQL password format. (You were introduced to this in Day 4, “Getting Hands-On with MySQL,” but it will be explained more thoroughly in ...

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.