postgres加密解密pgcrypto
create extension pgcrypto; --增加,加密解密模块; drop extension pgcrypto; --删除,加密解密模块;
定义--encrypt(bytea, bytea, text)-- update bill_his_yun set yun_ip=encode(encrypt('202.99','p08','des') ,'hex') where yun_id=299904910298845184; select decrypt(yun_ip,'p08','des') from bill_his_yun where yun_id=299904910298845184; select convert_from(decrypt(decode(yun_ip,'hex'),'p08','des'),'SQL_ASCII') as yun_ip from bill_his_yun where yun_id=299904910298845184; text加密方式 AES DES/3DES/CAST5 Blowfish 查询表时一定符合类型 select nm, encrypt(cast(tb1.nm as bytea) ,'aa','aes') from tb1 select nm,test, encrypt(cast(test as bytea) ,'aa','aes') as 加密, convert_from(decrypt(encrypt(cast(test as bytea),'aa','aes'),'aa','aes'),'SQL_ASCII') as 解密 from tb1 --------------------------------------------------------- select encrypt('123456年a','aa','aes'); --\000\003AXv\327\370\351\363\006\242\267A\245yX select convert_from(decrypt('\000\003AXv\327\370\351\363\006\242\267A\245yX','aa','aes'),'SQL_ASCII'); --123456年a select convert_from(decrypt(encrypt('123456年a','aa','aes'),'aa','aes'),'SQL_ASCII'); --123456年a —————
分类:
postgersql
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现