我正在尝试使用“ pgp_sym_encrypt”查询postgres中的加密字段。我通过将表中的所有名字设置为加密值来运行测试:
update person set first_name = pgp_sym_encrypt('test', 'password');
Run Code Online (Sandbox Code Playgroud)
然后选择:
select * from person where first_name = pgp_sym_encrypt('test', 'password');
Run Code Online (Sandbox Code Playgroud)
这将不返回任何结果。
如果我将其更改为使用常规的postgres加密,它将返回表中的所有行:
update person set first_name = encrypt('test', 'password', 'aes');
select * from person where first_name = encrypt('test', 'password', 'aes');
Run Code Online (Sandbox Code Playgroud)
我当前的postgres版本是:postgres(PostgreSQL)9.4.0。在这种情况下,first_name字段是一个bytea字段。
有谁知道为什么不能使用“ pgp_sym_encrypt”来工作?
谢谢!