加密库? [英] Encryption libraries?
问题描述
作为我计划做的一些背景,我只需要使用私钥(.pfx)加密邮件,并使用公钥(.cer)进行解密。尽管可能在将来,该项目的这个级别不需要消息签名和身份验证。
我已经看到加密长度的引用,这让我不安。我们需要能够加密任何长度的消息(在理由当然!)。这是我需要担心的事情,如果是这样,有办法处理吗?
我不希望在窗口中存储公钥/私钥证书管理员如果可能的话,但是如果它使实现显着简单,那么就这样。
我意识到PKI和加密是一个大而复杂的主题,希望一个相对简单的图书馆...(可以希望,对吧?)
谢谢!
嗯,你没有提到内置的类不能满足你的需要,所以关于 System.Security.Cryptography.RSACryptoServiceProvider ?
它有一个很大的设定合法的方法来对流进行不对称加密/解密。
有几个教程/指南可以让你沿途:
http://www.codeproject.com/KB/security/RSACryptoPad.aspx
http:// www .eggheadcafe.com / articles / 20020630.asp
通过 Google 。
更新:关于长度限制,如果您只是在双方实施相同的缓冲算法,加密和解密,则不应该是任何问题。
Update2 :是的,我的示例是 RSACryptoProvider ,但您可以使用派生自 System.Security.Cryptography.Asymmetr icAlgorithm ,如果您需要公钥/私钥解决方案。或者建立自己的...或者可能不是:)
I have been tasked with implementing a PKI library in C# for a company project, and have been unable to find a good implementation of it. There appear to be multiple libraries, and many broken links pointing to MSDN libraries that have been removed. I've seen people using Crypt32.dll, people building their own libraries, people using P/Invoke to access system certificate stores, people extending the built-in libraries, examples that simply don't apply to C# (e.g. Java examples), and commercial libraries.
My question is, which implementation/library is most recommended for simple encryption/decryption of data?
As some background for what I plan to do with it, I simply need to encrypt messages using a private key (.pfx), and decrypt with public keys (.cer). Message signing and authentication isn't required at this level of the project, although it may be in future. I have seen reference to encryption lengths which make me uneasy. We need to be able to encrypt any length message (within reason, of course!). Is this something I need to worry about, and if so, is there a way to deal with it?
I would prefer not to store public/private keys in the windows certificate manager if at all possible, but if it makes implementation significantly simpler, so be it.
I realize PKI and encryption is a large and complex subject, but I'm hoping for a relatively simple library anyway... (one can hope, right?)
Thanks!
Well, you did not mention that the built-in class doesn't cover your need, so how about System.Security.Cryptography.RSACryptoServiceProvider?
It has a large set qualified ways to asymmetrically encrypt/decrypt streams.
There are several tutorial/guides to take you along the way:
http://www.codeproject.com/KB/security/RSACryptoPad.aspx
http://www.eggheadcafe.com/articles/20020630.asp
There are countless more to be found through Google.
Update: About the length-restrictments, it's should not be any problems if you just implement the same buffer-algorithm on both sides, encryption and decryption.
Update2: Yes, my example was RSACryptoProvider, but you can use any class that derives from System.Security.Cryptography.AsymmetricAlgorithm, if you want a public/private key-solution. Or build your own... or maybe not :)
这篇关于加密库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!