Mysql Md5 Function

MySQL: MD5 Function

This tutorial explains how to use the MySQL MD5 function with syntax and examples.

Description

The MySQL MD5 function returns an MD5 128-bit checksum representation of a string.

Syntax

The syntax for the MD5 function in MySQL is:

MD5( string )

Parameters or Arguments

string

The plaintext string used to generate the MD5 128-bit checksum.

Note

  • The MD5 function will return a 32 character hex string as the result.
  • The MD5 function will return NULL, if the string was NULL.
  • The result from the MD5 function can be used a hash key.

Applies To

The MD5 function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23.2

Example

Let's look at some MySQL MD5 function examples and explore how to use the MD5 function in MySQL.

For example:

mysql> SELECT MD5('abc');
Output: '900150983cd24fb0d6963f7d28e17f72'

mysql> SELECT MD5('password');
Output: '5f4dcc3b5aa765d61d8327deb882cf99'

mysql> SELECT MD5('AODBA');
Output: 'cf2318ef9f508f3db56da2aeb6a7f829'

mysql> SELECT MD5(NULL);
Output: NULL