近期测试了一下postgresql的加密扩展插件pgcrypto的aes加密
安装加密扩展插件:pgcrypto
在主节点上安装
create extension pgcrypto;
aes加解密函数简单介绍
encrypt(data bytea, key bytea, type text) --加密
decrypt(data bytea, key bytea, type text) --解密
data 是需要加密的数据;type 用于指定加密方法
ASE方式加密:
select encrypt('postgres','abc','aes');
解密:
select convert_from(decrypt('\xd664687424b2806001d0744177284420','abc','aes'),'SQL_ASCII');
建表测试一下
test=# create table user_test(username varchar(20),password varchar(60));
CREATE TABLE
test=# insert into user_test values('miya',encode(encrypt('123','abc','aes'),'hex'));
INSERT 0 1
test=# insert into us