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.
- https://github.com/krcs/SQLServerCrypto
- https://docs.microsoft.com/en-us/sql/t-sql/functions/encryptbypassphrase-transact-sql?view=sql-server-2017
- https://docs.microsoft.com/en-us/sql/t-sql/functions/decryptbypassphrase-transact-sql?view=sql-server-2017
- https://blogs.msdn.microsoft.com/sqlsecurity/2009/03/30/sql-server-encryptbykey-cryptographic-message-description/
- https://stackoverflow.com/questions/21684733/c-sharp-decrypt-bytes-from-sql-server-encryptbypassphrase