我对编码密码有一些问题,我该怎么办呢.编码类型md5
digest(data text,type text) returns bytea; CREATE OR REPLACE FUNCTION md(bytea) returns text AS $$ SELECT encode(digest($1,'sha1'),'md5') $$LANGUAGE sql STRICT IMMUTABLE; INSERT INTO "login"(login,password,employee_id) VALUES ( 'email',crypt('password',md('md5')),1);
***错误***
ERROR: Syntax error at or near "digest" sql state: 42601 Character: 1
摘要(数据文本,类型文本)返回bytea;是无效的语法.
原文链接:https://www.f2er.com/postgresql/192028.html我推荐使用bcrypt.无需其他功能定义:
INSERT into "login" (login,employee_id) VALUES ('email',gen_salt('bf'));
后来…
UPDATE table SET password = crypt('password',gen_salt('bf'))
并检查密码:
SELECT ... FROM table WHERE password is NOT NULL AND password = crypt('password-to-test',password);
Crafted Software和Jeff Atwood推荐Bcrypt.official pgcrypto docs也可能是有意义的.