SQL functions for SHA hashes (sha1, sha256, sha384, sha512)

A number of SQL functions for the SHA-family of cryptographic hashes have been added to Invantive SQL:

  • sha1: hash value using the SHA-1 hashing algorithm (see SHA-1 - Wikipedia),
  • sha256: hash value using the SHA-2 algorith with a digest length of 256 bits (see SHA-2 - Wikipedia),
  • sha384: hash value using the SHA-2 algorith with a digest length of 384 bits (see SHA-2 - Wikipedia),
  • sha512: hash value using the SHA-2 algorith with a digest length of 512 bits (see SHA-2 - Wikipedia).

These hash functions all accept a text or BLOB as input values, and return a hexadecimal hash value.

The following SQL-expression will always calculate the SHA1 hash of a constant text:

select sha1('my input')

The following SQL-expression will always calculate the SHA1 hash of a random binary string:

select sha1(random_blob(16))

Related to the SHA hash functions is the also available MD5 SQL-function.

Availability

The cryptographic hash functions of the SHA-family are available starting release 22.0.630 and BETA release 22.1.190.