Showing posts with label Obfuscation using SQL Server ENCRYPTBYPASSPHRASE and DECRYPTBYPASSPHRASE functions. Show all posts
Showing posts with label Obfuscation using SQL Server ENCRYPTBYPASSPHRASE and DECRYPTBYPASSPHRASE functions. Show all posts

Monday, 29 October 2018

Obfuscation using SQL Server ENCRYPTBYPASSPHRASE and DECRYPTBYPASSPHRASE functions

--Obfuscation using SQL Server ENCRYPTBYPASSPHRASE and DECRYPTBYPASSPHRASE functions

-- 01 Obfucate (encrypt) Value

-- Theory Obfucate Value
-- select EnCRYPTBYPASSPHRASE('Phrase to use to decode','Value to encrypt')

-- Example Obfucate Value
select ENCRYPTBYPASSPHRASE('Test1','Test');


-- 02 Unobfucate (unencrypt) Value

-- Theory decrypt Value
-- select convert(varchar(max),DECRYPTBYPASSPHRASE('Phrase to use to decode',EnCRYPTBYPASSPHRASE('Phrase to use to decode','Value to encrypt')));

-- Example decrypt value
select convert(varchar(max),DECRYPTBYPASSPHRASE('Test1',EnCRYPTBYPASSPHRASE('Test1','Test')));