HMAC Functions

HMAC_MD5

HMAC_MD5(x, key) Computes the MD5 HMAC of the bytes value x using key as the key.

SELECT HMAC_MD5('foo', 'bar')
'Mbbbnl60rdtC8abKBzZ63A=='
SELECT HMAC_MD5('foo', null)
null

HMAC_SHA1

HMAC_SHA1(x, key) Computes the SHA1 HMAC of the bytes value x using key as the key.

SELECT HMAC_SHA1('foo', 'bar')
'hdFVxV7ShqMAvRzxJN4I2H6RTzo='
SELECT HMAC_SHA1('foo', null)
null

HMAC_SHA256

HMAC_SHA256(x, key) Computes the SHA256 HMAC of the bytes value x using key as the key.

SELECT HMAC_SHA256('foo', 'bar')
'FHkzIYqqvAuLEKKzpcNGhMjZQ0G88QpHNtxycPd0GFE='
SELECT HMAC_SHA256('foo', null)
null

HMAC_SHA512

HMAC_SHA512(x, key) Computes the SHA512 HMAC of the bytes value x using key as the key.

SELECT HMAC_SHA512('foo', 'bar')
'JCV9chBYKmXHMexVFZyBhMwkwCSJRT5YWH9x9EwjotYbS3IVSonRey1JRIqEUuoGb0/FaivOrUXAiFcv/M2z2A=='
SELECT HMAC_SHA512('foo', null)
null

HMAC

HMAC(x, key, digest) Computes the HMAC of the bytes value x using key as the key and digest as the digest method, where digest is is one of the OpenSSL digest methods md5, sha1, sha256, or sha512 (case insensitive).

SELECT HMAC('foo', 'bar', 'md5')
'Mbbbnl60rdtC8abKBzZ63A=='
SELECT HMAC('foo', 'bar', 'sha256')
'FHkzIYqqvAuLEKKzpcNGhMjZQ0G88QpHNtxycPd0GFE='