寻求sqlserver2005非对称加密实现
目前网上找来找去,都是对称加密的例子,哪位用过非对称加密rsa加密的方法,请提供脚本示例!3ks
------解决方案--------------------不太了解,帮顶~~~
------解决方案--------------------顶下,期待解决
------解决方案----------------------1) 创建非对称密钥
CREATE ASYMMETRIC KEY asy_TestKey WITH ALGORITHM = RSA_1024
ENCRYPTION BY PASSWORD = 'bmsA$dk7i82bv55foajsd9764 '
GO
SELECT * FROM sys.asymmetric_keys
--2) 创建示例表
USE TestDb
IF EXIST dbo.EmpSalary DROP TABLE dbo.EmpSalary;
CREATE TABLE EmpSalary(
EmpID int,
Title nvarchar(50),
Salary varbinary(500)
)
GO
--3) 向表中插入数据,并对Salary列的数据进行加密
INSERT INTO EmpSalary VALUES (1, 'CEO ', EncryptByAsymKey(AsymKey_ID( 'asy_TestKey2 '), '20000 '))
INSERT INTO EmpSalary VALUES (2, 'Manager ', EncryptByAsymKey(AsymKey_ID( 'asy_TestKey2 '), '10000 '))
INSERT INTO EmpSalary VALUES (3, 'DB Admin ', EncryptByAsymKey(AsymKey_ID( 'asy_TestKey2 '), '5000 '))
GO
--4) 查看表中存放的数据
SELECT * FROM EmpSalary
--5) 解密被加密了的数据列
SELECT EmpID, Title,CONVERT(varchar(20),
DecryptByAsymKey( AsymKey_Id( 'asy_TestKey2 '),
Salary, N 'bmsA$dk7i82bv55foajsd9764 ' )) as DecryptSalary,salary as EncryptSalary
FROM EmpSalary
------解决方案--------------------这个要支持一下