Encrypt data with a passphrase using the TRIPLE DES algorithm with a 128 key bit length.
DECLARE @plain_text NVARCHAR(1000)
SET @plain_text = 'Hello123'
DECLARE @passphrase NVARCHAR(1000)
SET @passphrase = N'My Passphrase';
DECLARE @encrypted_string VARBINARY(MAX)
SET @encrypted_string = EncryptByPassPhrase(@passphrase, @plain_text)
DECLARE @decrypted_string NVARCHAR(1000)
SET @decrypted_string = DecryptByPassPhrase(@passphrase, @encrypted_string);
PRINT @plain_text
PRINT @encrypted_string
PRINT @decrypted_string
Sources:
Comments