Hashing Functions

This topic describes the built-in cryptographic hash algorithms. The hash functions operate on literal values.

  • MD5: Converts values to an MD5 128-bit hash value.
  • SHA1: Converts values to a SHA 160-bit hash value.
  • SHA256: Converts values to a SHA 256-bit hash value.
  • SHA384: Converts values to a SHA 384-bit hash value.
  • SHA512: Converts values to a SHA 512-bit hash value.

Hash Function Syntax

Use the following syntax when incorporating hash functions in queries:

FUNCTION(expression)

Where expression evaluates to the literal values to hash.

Hash Function Examples

The example below queries the sample Tickit data set to convert social security and credit card numbers to SHA 256-bit hash values.

SELECT (SHA256(?card) AS ?sha2_card) (SHA256(?ssn) AS ?sha2_ssn)
FROM <tickit>
WHERE {
?person <ssn> ?ssn; <card> ?card. }
sha2_card                                          | sha2_ssn
---------------------------------------------------+----------------------------------------------------
510c58d09f11427bea479e47b67bad8bc7def1feb69f12b2ad | 9aa3f8c117a40fd521862f7e107c1eaa526e4b58b37acb49b0
ff146b71079ac27e18f8534b2868ade868a02b3b8eaadc42eb | 4e69800254da555bb468a805d6de15664b627f3572e55f69a5
7ebd8c61a22a96350422f823dbe33eb2401ecd23732b1e8432 | 10f189f6531045e71ef37a25453f42c921867dc83906922691
d322e276bd4cd47bfc34a42a4cf5be352a0d182724271d7b85 | 1ea6616346734796ffefd75bb565f757a1aa055633b1a48b07
4738b5a16616c7e7d2ad87d25f017da847421547680228b621 | b97bf37adfa7b46a9138f13633480841ba4fbbec4e549d9d4c
fcdbe8ba1f83c8228911854241db08a897ea2780e08d70697d | fbdfa110b595eb44304cf4f505af573799d1492fa78306eed5
...
49990 rows