summaryrefslogtreecommitdiffstats
path: root/contrib/pgcrypto/sql/3des.sql
blob: 1b71a108c21929a8aeddecd0e552e8c7b1dacd58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--
-- 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');