Relix

Language reference

SHA256 (a string's SHA-256 digest, in hex)

Syntax

SHA256(<string>)

π customer_id, SHA256(email) → digest (Customers)

Description

SHA256 gives the SHA-256 digest of a string as 64 lowercase hexadecimal characters: SHA256('a') is 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb'. It fingerprints a value as MD5 does, with a digest no one has found two inputs to share.

Technical Description

SHA256(s: STRING) → STRING. The digest of the UTF-8 bytes of s, in lowercase hex, the same as SHA2(s, 256). NULL input returns NULL. PURE, DETERMINISTIC.

Examples

A digest of each customer's email:

π customer_id, SHA256(email) → digest (Customers)

Pushdown

SQL: encode(sha256(convert_to(…, 'UTF8')), 'hex') on PostgreSQL, SHA2(…, 256) on MySQL and SHA256(…) on DuckDB. Elsewhere it runs in the engine.

SQL names

DuckDB's SHA256(s), MySQL's SHA2(s, 256) (SHA2), and PostgreSQL's encode(sha256(convert_to(s, 'UTF8')), 'hex'). SQL Server's HASHBYTES('SHA2_256', s) and Oracle's STANDARD_HASH(s, 'SHA256') are HASHBYTES and STANDARD_HASH.

See Also

sha2, md5, sha1