mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-25 05:17:19 +02:00
This was from before the hex format was available in bytea. Now we can remove the extra explicit encoding/decoding calls and rely on the default output format. Discussion: https://www.postgresql.org/message-id/flat/17dcb4f7-7ac1-e2b6-d5f7-2dfba06cd9ee%40enterprisedb.com
73 lines
2.0 KiB
Plaintext
73 lines
2.0 KiB
Plaintext
--
|
|
-- HMAC-MD5
|
|
--
|
|
SELECT hmac(
|
|
'Hi There',
|
|
'\x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b'::bytea,
|
|
'md5');
|
|
hmac
|
|
------------------------------------
|
|
\x9294727a3638bb1c13f48ef8158bfc9d
|
|
(1 row)
|
|
|
|
-- 2
|
|
SELECT hmac(
|
|
'Jefe',
|
|
'what do ya want for nothing?',
|
|
'md5');
|
|
hmac
|
|
------------------------------------
|
|
\x813aead7c4a34bff01a16d61368e7c13
|
|
(1 row)
|
|
|
|
-- 3
|
|
SELECT hmac(
|
|
'\xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'::bytea,
|
|
'\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::bytea,
|
|
'md5');
|
|
hmac
|
|
------------------------------------
|
|
\x56be34521d144c88dbb8c733f0e8b3f6
|
|
(1 row)
|
|
|
|
-- 4
|
|
SELECT hmac(
|
|
'\xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'::bytea,
|
|
'\x0102030405060708090a0b0c0d0e0f10111213141516171819'::bytea,
|
|
'md5');
|
|
hmac
|
|
------------------------------------
|
|
\x697eaf0aca3a3aea3a75164746ffaa79
|
|
(1 row)
|
|
|
|
-- 5
|
|
SELECT hmac(
|
|
'Test With Truncation',
|
|
'\x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c'::bytea,
|
|
'md5');
|
|
hmac
|
|
------------------------------------
|
|
\x56461ef2342edc00f9bab995690efd4c
|
|
(1 row)
|
|
|
|
-- 6
|
|
SELECT hmac(
|
|
'Test Using Larger Than Block-Size Key - Hash Key First',
|
|
'\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::bytea,
|
|
'md5');
|
|
hmac
|
|
------------------------------------
|
|
\x6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd
|
|
(1 row)
|
|
|
|
-- 7
|
|
SELECT hmac(
|
|
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
|
'\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::bytea,
|
|
'md5');
|
|
hmac
|
|
------------------------------------
|
|
\x6f630fad67cda0ee1fb1f562db3aa53e
|
|
(1 row)
|
|
|