mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-24 23: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
26 lines
849 B
SQL
26 lines
849 B
SQL
--
|
|
-- 3DES cipher
|
|
--
|
|
|
|
-- test vector from somewhere
|
|
SELECT encrypt('\x8000000000000000',
|
|
'\x010101010101010101010101010101010101010101010101',
|
|
'3des-ecb/pad:none');
|
|
|
|
select encrypt('', 'foo', '3des');
|
|
-- 10 bytes key
|
|
select encrypt('foo', '0123456789', '3des');
|
|
-- 22 bytes key
|
|
select encrypt('foo', '0123456789012345678901', '3des');
|
|
|
|
-- decrypt
|
|
select encode(decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des'), 'escape');
|
|
|
|
-- iv
|
|
select encrypt_iv('foo', '0123456', 'abcd', '3des');
|
|
select encode(decrypt_iv('\x50735067b073bb93', '0123456', 'abcd', '3des'), 'escape');
|
|
|
|
-- long message
|
|
select encrypt('Lets try a longer message.', '0123456789012345678901', '3des');
|
|
select encode(decrypt(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), '0123456789012345678901', '3des'), 'escape');
|