mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
27 lines
827 B
Plaintext
27 lines
827 B
Plaintext
--
|
|
-- crypt() and gen_salt(): bcrypt
|
|
--
|
|
select crypt('', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O');
|
|
crypt
|
|
--------------------------------------------------------------
|
|
$2a$06$RQiOJ.3ELirrXwxIZY8q0OlGbBEpDmx7IRZlNYvGJ1SHXwNi2cEKK
|
|
(1 row)
|
|
|
|
select crypt('foox', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O');
|
|
crypt
|
|
--------------------------------------------------------------
|
|
$2a$06$RQiOJ.3ELirrXwxIZY8q0OR3CVJrAfda1z26CCHPnB6mmVZD8p0/C
|
|
(1 row)
|
|
|
|
create table ctest (data text, res text, salt text);
|
|
insert into ctest values ('password', '', '');
|
|
update ctest set salt = gen_salt('bf', 8);
|
|
update ctest set res = crypt(data, salt);
|
|
select res = crypt(data, res) as "worked" from ctest;
|
|
worked
|
|
--------
|
|
t
|
|
(1 row)
|
|
|
|
drop table ctest;
|