mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-28 19:47:20 +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.1 KiB
Plaintext
73 lines
2.1 KiB
Plaintext
--
|
|
-- HMAC-SHA1
|
|
--
|
|
SELECT hmac(
|
|
'Hi There',
|
|
'\x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b'::bytea,
|
|
'sha1');
|
|
hmac
|
|
--------------------------------------------
|
|
\x675b0b3a1b4ddf4e124872da6c2f632bfed957e9
|
|
(1 row)
|
|
|
|
-- 2
|
|
SELECT hmac(
|
|
'Jefe',
|
|
'what do ya want for nothing?',
|
|
'sha1');
|
|
hmac
|
|
--------------------------------------------
|
|
\x156d4c35468a0339f3fa57a067bf47f814eb7a57
|
|
(1 row)
|
|
|
|
-- 3
|
|
SELECT hmac(
|
|
'\xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'::bytea,
|
|
'\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::bytea,
|
|
'sha1');
|
|
hmac
|
|
--------------------------------------------
|
|
\xd730594d167e35d5956fd8003d0db3d3f46dc7bb
|
|
(1 row)
|
|
|
|
-- 4
|
|
SELECT hmac(
|
|
'\xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'::bytea,
|
|
'\x0102030405060708090a0b0c0d0e0f10111213141516171819'::bytea,
|
|
'sha1');
|
|
hmac
|
|
--------------------------------------------
|
|
\x4c9007f4026250c6bc8414f9bf50c86c2d7235da
|
|
(1 row)
|
|
|
|
-- 5
|
|
SELECT hmac(
|
|
'Test With Truncation',
|
|
'\x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c'::bytea,
|
|
'sha1');
|
|
hmac
|
|
--------------------------------------------
|
|
\x37268b7e21e84da5720c53c4ba03ad1104039fa7
|
|
(1 row)
|
|
|
|
-- 6
|
|
SELECT hmac(
|
|
'Test Using Larger Than Block-Size Key - Hash Key First',
|
|
'\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::bytea,
|
|
'sha1');
|
|
hmac
|
|
--------------------------------------------
|
|
\xaa4ae5e15272d00e95705637ce8a3b55ed402112
|
|
(1 row)
|
|
|
|
-- 7
|
|
SELECT hmac(
|
|
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
|
'\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::bytea,
|
|
'sha1');
|
|
hmac
|
|
--------------------------------------------
|
|
\xe8e99d0f45237d786d6bbaa7965c7808bbff1a91
|
|
(1 row)
|
|
|