MySQL | MD5 Function

The MySQL MD5 function is used to return an MD5 128-bit checksum representation of a string. The MD5 message-digest algorithm is a widely used hash function producing a 128-bit hash value. The value returned by the MD5 function is a binary string of 32 hexadecimal digits, or NULL if the argument was NULL.

The return value can also be used as a hash key. The MD5 function accepts one parameter which is the string to be encrypted.

Syntax:



MD5( plain_string )

Parameters Used:

  • plain_string – It is used to specify the plain text string that is to be encrypted.

Return Value:
The MD5 function in MySQL returns a binary string of 32 hexadecimal digits.

Supported Versions of MySQL:

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1

Example-1: Implementing MD5 function on a string.

SELECT 
MD5('xyz'); 

Output:

d16fb36f0911f878998c136191af705e 

Example-2: Implementing MD5 function on a string with a combination of characters and integer values.

SELECT 
MD5('xyz123'); 

Output:

j89hj65l0355k878998c136191kl906w 

Example-3: Implementing MD5 function on a bigger string.

SELECT 
MD5('geeksforgeeks'); 

Output:

a6eb56f80be8a120436d6f1c9b8d87ca 

Example-4: Implementing MD5 function on a NULL string.

SELECT 
MD5('NULL'); 

Output:

NULL 
My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.