sha256()

A function computing a SHA-256 hash

sha256() is a system function or computing the SHA-256 hash of the provided binary string.

sha256() was added in PostgreSQL 11.

Usage

sha256 ( bytea ) → bytea

Change history

Examples

Basic usage example for sha256():

postgres=# SELECT sha256('foo'::bytea);
                               sha256                               
--------------------------------------------------------------------
 \x2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
(1 row)

Return the generated hash as a text string:

postgres=# SELECT encode(sha256('foo'::bytea), 'hex');
                              encode                              
------------------------------------------------------------------
 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
(1 row)

Categories

System function

See also

sha224(), sha384(), sha512(), md5()