解密从.NET的SQL Server加密数据 [英] Decrypt SQL Server encrypted data from .net

查看:160
本文介绍了解密从.NET的SQL Server加密数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能被从内部.NET存储在SQL Server列EncryptByCert加密数据进行解密?

Is it possible to decrypt the EncryptByCert-encrypted data that is stored in a SQL Server column from within .net?

我想使用 EncryptByCert 在存储过程中存储一个值的RSA-encrpyted中的一列。然后,客户端应用程序连接到SQL Server,并要求EN codeD数据,然后需要去code与证书的私钥。这可能吗?

I want to use EncryptByCert in a stored procedure to store a value RSA-encrpyted in a column. Then a client application will connect to SQL Server and request the encoded data and then needs to decode with the private key of the certificate. Is this possible?

我没有加密深刻的认识。这就是为什么我问这个问题。也许有一个很好的例子,这样做呢?

I don't have a profound knowledge of encryption. That's why I ask this question. Maybe there is a good example for doing this?

推荐答案

SQL Server加密数据以字节,返回此作为结果的顺序。有是没有使用的容器格式。因此,它可以直接通过的RSACryptoServiceProvider 解密。重要的是这里的话是,SQL Server使用PKCS#1 V1.5填充(至少SQL Server 2005中)。

SQL Server encrypts the data to a sequence of bytes and returns this as the result. There is no container format used. Therefore, It can directly be decrypted by the RSACryptoServiceProvider. Important to remark here is, that SQL Server uses PKCS #1 V1.5 padding (at least SQL Server 2005).

有一点需要注意:
SQL服务器返回的加密结果以相反的顺序,因为它是从的RSACryptoServiceProvider 所需。因此,字节序列与 RSACryptoServiceProvider.Decrypt 解密之前被逆转。

One thing to notice:
SQL server returns the encrypted result in reverse order as it is desired from RSACryptoServiceProvider. Therefore the byte sequence has to be reversed before decrypting it with RSACryptoServiceProvider.Decrypt.

这篇关于解密从.NET的SQL Server加密数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆