The repository contains methods written in Go mapping the functionality of two
built-in SQL Server functions:
EncryptByPassPhrase
and
DecryptByPassPhrase.
These functions are used to encrypt a given string of characters or decrypt the
ciphertext.
The result returned by the EncryptByPassphrase function
can be decrypted using the DecryptByPassPhrase function on SQL Server. Also the
DecryptByPassphrase method can decrypt
ciphertext generated by the EncryptByPassPhrase function on SQL Server.
The EncryptByPassphrase method creates a V2 encrypted message.
The DecryptByPassphrase function reads the version number from the ciphertext.
Msg Version
Crypto
SQL Server Versions
Supported
V1
TripleDES / SHA1
SQL Server 2008 - SQL Server 2016
No
V2
AES256 / SHA256
SQL Server 2017
Yes
This does not support add_authenticator and authenticator arguments, which are
optional in the SQL Server methods.
EncryptByPassphrase creates an encrypted byte slice matching the same
format and as the SQL Server function. It creates a V2 format, without
authenticator.
It can be decrypted by SQL Server 2017 or later.