日期:2014-05-18 浏览次数:20778 次
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '??xxx' CREATE SYMMETRIC KEY dcmy WITH ALGORITHM = DES ENCRYPTION BY PASSWORD = 'xxx??' --打开对称密钥 OPEN SYMMETRIC KEY dcmy DECRYPTION BY PASSWORD = 'xxx??' --以加密的方式存放数据 INSERT INTO [tb_Teacher] (TeaName,TeaPwd) VALUES ( '老师五', EncryptByKey(Key_GUID('dcmy'), '456456') ) select * from tb_Teacher select CONVERT(varchar, DecryptByKey(TeaPwd)) from tb_Teacher
create table [tb_Teacher] (TeaName nvarchar(20) ,TeaPwd nvarchar(200)); GO CREATE SYMMETRIC KEY dcmy WITH ALGORITHM = DES ENCRYPTION BY PASSWORD = '1234567890' --打开对称密钥 OPEN SYMMETRIC KEY dcmy DECRYPTION BY PASSWORD = '1234567890' --以加密的方式存放数据 INSERT INTO [tb_Teacher] (TeaName,TeaPwd) VALUES ( '老师五', EncryptByKey(Key_GUID('dcmy'), '456456') ) select * from tb_Teacher /* TeaName TeaPwd -------------------- ----------------- 老师五 ?菮??劦洼?? ????娺簍???? */ select CONVERT(varchar, DecryptByKey(TeaPwd)) from tb_Teacher /* 456456 */