当前位置:网站首页>Symmetric encryption, certificate encryption
Symmetric encryption, certificate encryption
2022-04-23 12:03:00 【I boiled the night white_】
-------------------------------------------------------- Symmetric encryption ---------------------------
create table Employee_encryption
(
Eid char(5) primary key not null,
Did char(4) not null,
Ename char(10) not null,
Esex char(2) not null,
Ebirth date check(Ebirth>='1956-1-1' and Ebirth<='2050-1-1'),
salary varbinary(1000) not null,
foreign key(Did) references Department(Did)
)
-- Create a database master key
CREATE MASTER KEY ENCRYPTION BY PASSWORD ='1209QQ-1'
-- Create a symmetric key using the database master key
CREATE SYMMETRIC KEY salaryKey
WITH ALGORITHM =AES_256
ENCRYPTION BY PASSWORD = '1209QQ-1'
-- Open symmetric key PWDKEY
OPEN SYMMETRIC KEY salaryKey
DECRYPTION BY PASSWORD = '1209QQ-1'
-- insert data
insert into Employee_encryption(Eid,Did,Ename,Esex,Ebirth,salary) values
('60301','1001','xxx',' Woman ','2000-05-01',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'3000')),
('60403','2002','xxx',' Woman ','2000-08-23',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'2500')),
('30124','3002',' Song Zhihao ',' male ','1998-09-11',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'3600')),
('21004','3003',' Jialin ',' male ','1993-07-09',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'1369')),
('02305','5003',' Shijia ',' Woman ','2000-01-03',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'2596')),
('04506','4001',' Du Bang Bang ',' male ','1992-08-25',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'3654')),
('05607','1001',' Xiao Lin ',' Woman ','1997-04-29',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'1515')),
('00228','4002',' Song Jia ',' male ','1978-09-30',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'9600')),
('40109','2003',' beautiful ',' Woman ','1999-10-17',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'6800')),
('40518','5002',' Beautiful ',' Woman ','1999-03-08',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'50000'))
SELECT Eid,Did,Ename,Esex,Ebirth,CONVERT(VARCHAR,DECRYPTBYKEY(salary)) as salary FROM Employee_encryption
CLOSE SYMMETRIC KEY salaryKey
------------------------- Encrypt the database with a certificate --------------------------------
-- Add column
ALTER TABLE Employee_encryption ADD marriage varbinary(1000)
-- Delete column
ALTER TABLE Employee_encryption DROP COLUMN marriage
CREATE CERTIFICATE CER_MARRIAGE
WITH SUBJECT='encrypt balance', -- The subject of the certificate
START_DATE='01/01/2022', -- Certificate activation date
EXPIRY_DATE= '06/12/2022' -- Certificate expiration date
--DROP CERTIFICATE CER_BALANCE
INSERT INTO Employee_encryption values
('90000','5001',' certificate 1',' male ','1988-08-08',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'1000'),ENCRYPTBYCERT(CERT_ID('CER_MARRIAGE'),'1')),
('90001','5001',' certificate 2',' Woman ','2013-01-05',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'5300'),ENCRYPTBYCERT(CERT_ID('CER_MARRIAGE'),'0')),
('90002','5001',' certificate 3',' male ','1976-03-04',ENCRYPTBYKEY(KEY_GUID('salaryKey'),'6300'),ENCRYPTBYCERT(CERT_ID('CER_MARRIAGE'),'1'))
--delete from Employee_encryption where eid='90000'
SELECT Eid,Did,Ename,Esex,Ebirth,
CONVERT(VARCHAR,DECRYPTBYKEY(salary)) as salary ,
CONVERT(VARCHAR,DECRYPTBYCERT(CERT_ID('CER_MARRIAGE'), marriage))
FROM Employee_encryption
版权声明
本文为[I boiled the night white_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231158303737.html
边栏推荐
- WIN10 启动后花屏
- 第四章 为IM 启用填充对象之启用和禁用列(IM-4.3 第三部分)
- 《通用数据保护条例》(GDPR)系列解读三:欧洲子公司如何向国内母公司回传数据?
- Nacos Foundation (9): Nacos configuration management from single architecture to microservices
- 第二十四课 经典问题解析
- 数据库如何填充IM表达式(IM 5.4)
- IM表达式如何工作(5.3)
- Database design of forum system
- Running error: unable to find or load the main class com xxx. Application
- Chapter 4 specifies the attribute of the inmemory column on the no inmemory table for im enabled filling objects: examples (Part IV of im-4.4)
猜你喜欢

NativeForMySQL 连接MySQL8 提示:1251- Client does not support authentication protocol

《通用数据保护条例》(GDPR)系列解读三:欧洲子公司如何向国内母公司回传数据?

云呐|固定资产盘点中,支持多种盘点方式(资产清查盘点)

Redis learning 5 - high concurrency distributed lock practice

面了一圈,整理了这套面试题。。

简易投票系统数据库设计

Nativeformysql connects to MySQL 8 prompt: 1251 - client does not support authentication protocol

5-minute NLP: text to text transfer transformer (T5) unified text to text task model

PSCP 基本使用

C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
随机推荐
On the integration of steam education in early childhood education
ES6学习笔记二
Summary of convolution layer and pooling layer
Analyze the rules for the use of robots with good performance
Relu function of activation function
Tensorflow uses keras to create neural networks
The fourth chapter is to enable the filling object of IM and enable ADO for im column storage (IM 4.8)
Chapter 4 is a tutorial on forced filling of in memory objects with IM enabled filling objects (IM 4.7)
Application of remote integrated monitoring system in power distribution room in 10kV prefabricated cabin project
第四章 为IM 启用填充对象之在NO INMEMORY表上指定INMEMORY列属性:示例(IM-4.4 第四部分)
Link sorting of tutorials such as assembly language running environment setting
怎么进行固定资产盘点,资产盘点报告如何一键生成
[web daily practice] eight color puzzle (float)
Interpretation of biological recognition in robot programming course
On lambda powertools typescript
软件测试对于减少程序BUG有多大帮助?
Next. JS static data generation and server-side rendering
Database design of forum system
thinkphp 添加图片文字水印生成带二维码的推广海报
Here comes the detailed picture and text installation tutorial of H5 game