PostgreSQL Tutorial: MD5 Function

September 19, 2023

The PostgreSQL MD5() function calculates the MD5 hash of a string and returns the result in hexadecimal.


The following illustrates the syntax of the MD5() function:



The MD5() function accepts one argument.

1) string

The string argument is the string of which the MD5 hash is calculated.

Return value

The MD5() function returns a string in TEXT data type.


The following example shows how to use the MD5() function to return the MD5 hash of the message 'PostgreSQL MD5':

SELECT MD5('PostgreSQL MD5');

The result is:

(1 row)

In this tutorial, you have learned how to use the PostgreSQL MD5() function to calculate the MD5 hash of a string.

comments powered by Disqus