当前位置:网站首页>sqlserver对数据进行加密、解密
sqlserver对数据进行加密、解密
2022-07-04 21:37:00 【CodingSir】
– sqlserver对数据进行加密、解密
– 创建测试表
CREATE TABLE TBLUser
(
Name nvarchar(30),
Password varbinary(1000)
)
- 1
- 2
- 3
- 4
- 5
– 创建数据库主**
CREATE master key ENCRYPTION BY PASSWORD ='[email protected]'
- 1
– 创建证书
CREATE CERTIFICATE TestCert with SUBJECT = 'Test Certificate'
- 1
– 创建对称**
CREATE SYMMETRIC KEY TestSymmetric WITH ALGORITHM = AES_256 ENCRYPTION BY CERTIFICATE TestCert
- 1
– 使用对称秘钥加密数据
OPEN SYMMETRIC KEY TestSymmetric DECRYPTION BY CERTIFICATE TestCert;
INSERT INTO TBLUser values('张三', ENCRYPTBYKEY(Key_Guid(N'TestSymmetric'), '123456'));
CLOSE SYMMETRIC KEY TestSymmetric;
- 1
- 2
- 3
– 查看加密后的数据
SELECT * FROM TBLUser
- 1
– 解密数据
OPEN SYMMETRIC KEY TestSymmetric DECRYPTION BY CERTIFICATE TestCert;
SELECT Name, CAST(DecryptByKey(password) as varchar(100)) Password FROM TBLUser;
CLOSE SYMMETRIC KEY TestSymmetric;
边栏推荐
- TCP shakes hands three times and waves four times. Do you really understand?
- 力扣98:验证二叉搜索树
- KDD2022 | 什么特征进行交互才是有效的?
- How to remove the black dot in front of the title in word document
- WebGIS框架---kalrry
- 开源之夏专访|Apache IoTDB社区 新晋Committer谢其骏
- GTEST from ignorance to proficiency (4) how to write unit tests with GTEST
- 机器人相关课程考核材料归档实施细则2022版本
- 如何借助自动化工具落地DevOps
- [C language] deep understanding of symbols
猜你喜欢
案例分享|金融业数据运营运维一体化建设
ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start
【C语言进阶篇】数组&&指针&&数组笔试题
Arcgis 10.2.2 | arcgis license server无法启动的解决办法
Application practice | Shuhai supply chain construction of data center based on Apache Doris
How was MP3 born?
QT—绘制其他问题
【LeetCode】17、电话号码的字母组合
Redis03 - network configuration and heartbeat mechanism of redis
QT—双缓冲绘图
随机推荐
服务线上治理
Interview question 01.01 Determine whether the character is unique
DevEco Device Tool 3.0 Release带来5大能力升级,让智能设备开发更高效
Interpreting the development of various intelligent organizations in maker Education
Monitor the shuttle return button
广电五舟与华为签署合作协议,共同推进昇腾AI产业持续发展
close系统调用分析-性能优化
Basic structure of PostgreSQL - table
Bookmark
AcWing 2022 每日一题
Golang interview finishing three resumes how to write
从RepVgg到MobileOne,含mobileone的代码
TCP protocol three times handshake process
Analysis of maker education technology in the Internet Era
开源之夏专访|Apache IoTDB社区 新晋Committer谢其骏
TCP三次握手,四次挥手,你真的了解吗?
Interviewer: what is XSS attack?
283. Moving zero-c and language assisted array method
Super detailed tutorial, an introduction to istio Architecture Principle and practical application
Cadre WebGIS - kalrry