PostgreSQL 可以对加密记录进行查询吗?
假设我的表中有一整列已加密,该表还有未加密的列(例如 ID),并且我有整列的加密密钥,并且我使用 DBMS 的 encrypt() 函数和 AES 来存储它。
我想知道是否有办法执行类似
SELECT * FROM table1 WHERE decrypt(col1, 'fooz', 'aes') = 'aValue'
我已经在 PostgreSQL 中尝试过的操作,并且不支持上述语法。如果没有办法做到这一点,有哪些解决方法?
我已经考虑解密到临时表,然后执行查询并将其删除,但这似乎效率极低且不安全,因为解密的表有可能保留在磁盘上
Let's say I have an entire column in a table that is encrypted, the table also has unencrypted columns like IDs, and I have the encryption key for the entire column and I used the DBMS' encrypt() function with AES to store it.
I'm wondering if there is anyway to execute something like
SELECT * FROM table1 WHERE decrypt(col1, 'fooz', 'aes') = 'aValue'
I've already tried that in PostgreSQL and the above syntax is not supported. If there is no way to do this, what are the workarounds?
I've looked into decrypting into a temporary table and then execute the query and drop it but that seems extremely inefficient and also unsafe because there's a chance the decrypted table can remain on disk
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
伪代码
或更具体地说:
真实代码
http://www.postgresql.org/docs/8.3/static/pgcrypto.html
Pseudo code
Or more specifically:
Real code
http://www.postgresql.org/docs/8.3/static/pgcrypto.html