centos 6.8 + postgresql 9.6 + pgcrypto

pgcrypto模块为PostgreSQL提供了密码函数。 简单使用了一下。

创建pgcrypto

mondb=# create extension pgcrypto;
CREATE EXTENSION

加密

mondb=# select encrypt('123我men','aa','aes');
              encrypt               
------------------------------------
 xe5fedda86a06a74d4bbea77c1d372385
(1 row)

解密

mondb=# select decrypt('xe5fedda86a06a74d4bbea77c1d372385','aa','aes');
       decrypt        
----------------------
 x313233e688916d656e
(1 row)

mondb=# select convert_from(decrypt('xe5fedda86a06a74d4bbea77c1d372385','aa','aes'),'SQL_ASCII');
 convert_from 
--------------
 123我men
(1 row)
原文地址:https://www.cnblogs.com/ctypyb2002/p/9792994.html