| 1 |
-- |
| 2 |
-- crypt() and gen_salt(): crypt-des |
| 3 |
-- |
| 4 |
|
| 5 |
SELECT crypt('', 'NB'); |
| 6 |
|
| 7 |
SELECT crypt('foox', 'NB'); |
| 8 |
|
| 9 |
-- We are supposed to pass in a 2-character salt. |
| 10 |
-- error since salt is too short: |
| 11 |
SELECT crypt('password', 'a'); |
| 12 |
|
| 13 |
CREATE TABLE ctest (data text, res text, salt text); |
| 14 |
INSERT INTO ctest VALUES ('password', '', ''); |
| 15 |
|
| 16 |
UPDATE ctest SET salt = gen_salt('des'); |
| 17 |
UPDATE ctest SET res = crypt(data, salt); |
| 18 |
SELECT res = crypt(data, res) AS "worked" |
| 19 |
FROM ctest; |
| 20 |
|
| 21 |
-- check disabling of built in crypto functions |
| 22 |
SET pgcrypto.builtin_crypto_enabled = off; |
| 23 |
UPDATE ctest SET salt = gen_salt('des'); |
| 24 |
UPDATE ctest SET res = crypt(data, salt); |
| 25 |
RESET pgcrypto.builtin_crypto_enabled; |
| 26 |
|
| 27 |
DROP TABLE ctest; |