Skip to content

Instantly share code, notes, and snippets.

@jrdmb
Created April 9, 2015 02:30
Show Gist options
  • Save jrdmb/ed98716aab76f73f9276 to your computer and use it in GitHub Desktop.
Save jrdmb/ed98716aab76f73f9276 to your computer and use it in GitHub Desktop.
Sql Server String Encryption
SELECT HASHBYTES('sha2_512', 'mypassword')
--algorithms: MD2 | MD4 | MD5 | SHA | SHA1 | SHA2_256 | SHA2_512
declare @enc varbinary(256)
select @enc = EncryptByPassPhrase('key', 'mypassword' )
--returns: 0x01000000D6191ADF19FF136F0A82E469E55AF781FC9D61904BA73039971C82FE88D3E758
select Cast(DECRYPTBYPASSPHRASE('key', @enc) as varchar(4000))
-- #sqlserver #tsql #encryption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment