解密PKCS#7加密数据在C#

解密PKCS#7加密数据在C#

本文介绍了解密PKCS#7加密数据在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发解决方案,需要解密PKCS#7加密数据,最好在C#中。据我所知,.NET api通过System.Security.Cryptography.Pkcs命名空间支持这一点。然而,似乎实现只能用于字节数组。那么当我有一个不适合内存的大型加密文件时,该怎么办?



我在这里缺少一些东西,还是有另一种方法呢一个Stream级别而不是使用bytearrays?

解决方案

.NET框架只有PKCS#7 / CMS的基本支持,所以它不支持流式传输数据。



您需要第三方库。正如其他人所说,BouncyCastle是一个很好的选择。它支持PKCS#7(PKCS#7也称为CMS)。



他们的测试可能是查找示例代码的好地方:。


I am working on a solution that needs to decrypt PKCS#7 encrypted data, preferably in C#. As far as I can see, the .NET api has support for this through the System.Security.Cryptography.Pkcs namespace. However it seems that the implementation can only work on byte arrays. So what do I do when I have a large encrypted file that does not fit into the memory?

Am I missing something here, or is there another way to do this on a Stream level instead of using bytearrays?

解决方案

The .NET framework has only rudimentary support for PKCS#7/CMS, so it does not support streaming the data.

You need a 3rd party library. As others have mentioned, BouncyCastle is an excellent choice. It does support PKCS#7 (PKCS#7 is also known as CMS).

Their tests are probably a good place to look for sample code: EnvelopedDataStreamTest.cs.

这篇关于解密PKCS#7加密数据在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 21:46