日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

pg加密扩展的安装_postgresql的加密扩展插件pgcrypto

發布時間:2023/12/19 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pg加密扩展的安装_postgresql的加密扩展插件pgcrypto 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

近期測試了一下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 user_test values('kimi',encode(encrypt('456','abc','aes'),'hex'));

INSERT 0 1

test=# select * from user_test;

username | password

----------+----------------------------------

miya | a4bf9afce727dbd2805393a86a24096c

kimi | 84279efc7942ca7364abcce78db90b0b

(2 rows)

解密后可以看出加密前的密碼

test=# select convert_from(decrypt(decode(password,'hex'),'abc','aes'),'SQL_ASCII') as real_pw,* from user_test;

real_pw | username | password

---------+----------+----------------------------------

123 | miya | a4bf9afce727dbd2805393a86a24096c

456 | kimi | 84279efc7942ca7364abcce78db90b0b

pgcrypto加密還支持很多如md5,bf等詳細可以查看官方文檔https://www.postgresql.org/docs/9.4/pgcrypto.html

找到篇寫的很詳細的博客可以查看一下:https://tonydong.blog.csdn.net/article/details/109073000

總結

以上是生活随笔為你收集整理的pg加密扩展的安装_postgresql的加密扩展插件pgcrypto的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。