加密库? [英] Encryption libraries?

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

问题描述

我的任务是在C#中为公司项目实施一个PKI库,并且无法找到一个很好的实现。似乎有多个库,许多断开的链接指向已删除的MSDN库。我看到人们使用Crypt32.dll,人们建立自己的图书馆,使用P / Invoke访问系统证书商店的人,扩展内置库的人员,根本不适用于C#的示例(例如Java示例),我的问题是,哪些实施/库最为推荐用于简单的数据加密/解密?



作为我计划做的一些背景,我只需要使用私钥(.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屋!

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