SQL2005 des加密算法存储过程

SQL2005 des加密算法存储过程

 

问题贴:http://topic.csdn.net/u/20100427/20/cb4e75ae-552f-443d-98ee-be1d0ddc0aa3.html?71166

--By Garnett_KG

 

CREATE SYMMETRIC KEY key1 WITH ALGORITHM=DES
    ENCRYPTION
BY PASSWORD='abc$123'
GO

OPEN SYMMETRIC KEY key1   
    DECRYPTION
BY PASSWORD='abc$123'

DECLARE @str NVARCHAR(100),@Encrypted VARBINARY(MAX)
SET @str=N'要加密的字串'   
SELECT @Encrypted=ENCRYPTBYKEY(KEY_GUID('key1'),@str)
SELEcT '加密'=@Encrypted ,'解密'=CAST(DECRYPTBYKEY(@Encrypted) AS NVARCHAR(100))
CLOSE SYMMETRIC KEY key1
GO
DROP SYMMETRIC KEY key1
GO

你可能感兴趣的:(Algorithm,sql,加密,算法,存储,encryption)