是否有可能被从内部.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
.