问题描述
遵循在C#中复制T-SQL DecryptByPassPhrase,我是无法使用 MSSQL 进行简单加密以在 C# 中解密.某些列中的加密值是必需的,因为该表会定期导出到 Excel 和 Access 中,因此简单的加密足以阻止"值,而无需让开发人员(重新)执行视图等.
Following Replicate T-SQL DecryptByPassPhrase in C#, I am unable to get a simple encryption with MSSQL to descrypt in C#. The encrypted values in certain columns is necessary because the table is exported into Excel and Access on a regular basis so simple encryption is more than enough to "block" values without having to involve developers to (re)do views, etc.
在 SQL Server 2012 中:
In SQL Server 2012:
在 C# 中:
工作的 C# 代码应该是什么样的?
What should working C# code look like?
谢谢.
推荐答案
SQL Server 2017 使用 SHA256 密码哈希 + AES-256 加密
SQL Server 2017 uses SHA256 hashing of password + AES-256 encryption
旧版本使用密码的 SHA1 散列 + 3DES-128 加密
Older versions use SHA1 hashing of password + 3DES-128 encryption
IV 大小与块大小相同:AES = 128 位,3DES = 64 位
IV size is the same as block size: AES = 128 bits, 3DES = 64 bits
填充模式:PKCS #7密码模式:CBC
Padding mode: PKCS #7 Cipher mode: CBC
服务器 2017 加密的数据以0x02"开头,旧版本以0x01"开头.
Data encrypted by server 2017 starts with "0x02", older versions start with "0x01".
这篇关于C# 从 SQL Server EncryptByPassPhrase 解密字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!