Encryption, Decryption in Sql
1 | -- encrypt function CREATE function [dbo].[Encrypt](@str nvarchar(max)) returns varbinary(max) as begin declare @encryptedValue varbinary(max) SET @encryptedValue = ENCRYPTBYPASSPHRASE('hDfR$h:)opK;@$ty&*$5rWER$&',@str) return @encryptedValue end -- decrypt function CREATE function [dbo].[Decrypt](@str varchar(max)) returns nvarchar(max) as begin declare @decryptedValue nvarchar(max) Set @decryptedValue = DECRYPTBYPASSPHRASE('hDfR$h:)opK;@$ty&*$5rWER$&',@str) return @decryptedValue end |
0 Comments