1-- 2-- crypt() and gen_salt(): bcrypt 3-- 4SELECT crypt('', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O'); 5 crypt 6-------------------------------------------------------------- 7 $2a$06$RQiOJ.3ELirrXwxIZY8q0OlGbBEpDmx7IRZlNYvGJ1SHXwNi2cEKK 8(1 row) 9 10SELECT crypt('foox', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O'); 11 crypt 12-------------------------------------------------------------- 13 $2a$06$RQiOJ.3ELirrXwxIZY8q0OR3CVJrAfda1z26CCHPnB6mmVZD8p0/C 14(1 row) 15 16-- error, salt too short: 17SELECT crypt('foox', '$2a$'); 18ERROR: invalid salt 19-- error, first digit of count in salt invalid 20SELECT crypt('foox', '$2a$40$RQiOJ.3ELirrXwxIZY8q0O'); 21ERROR: invalid salt 22-- error, count in salt too small 23SELECT crypt('foox', '$2a$00$RQiOJ.3ELirrXwxIZY8q0O'); 24ERROR: invalid salt 25CREATE TABLE ctest (data text, res text, salt text); 26INSERT INTO ctest VALUES ('password', '', ''); 27UPDATE ctest SET salt = gen_salt('bf', 8); 28UPDATE ctest SET res = crypt(data, salt); 29SELECT res = crypt(data, res) AS "worked" 30FROM ctest; 31 worked 32-------- 33 t 34(1 row) 35 36DROP TABLE ctest; 37