sql server2005自带的des加密解密方法

sql server2005自带的des加密解密方法

CREATE SYMMETRIC KEY key1 WITH ALGORITHM=DES

    ENCRYPTION BY PASSWORD='23kjdowlergam324ere'
GO


OPEN SYMMETRIC KEY key1    
    DECRYPTION BY PASSWORD='23kjdowlergam324ere'


DECLARE @str NVARCHAR(100),@Encrypted VARBINARY(MAX)
SET @str=N'123456'    
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,加密,server,解密,encryption,Go)