简体   繁体   English

.Net 中的私钥加密

[英]PRIVATE key encryption in .Net

I am looking for a way to do private key encryption in C#.我正在寻找一种在 C# 中进行私钥加密的方法。

I thought I could use the RSACryptoServiceProvider, but it only supports public key encryption.我以为我可以使用 RSACryptoServiceProvider,但它只支持公钥加密。

The only thing I found on the subject was this project, but I would rather use something I can find in .net: http://www.codeproject.com/KB/security/PrivateEncryption.aspx我在这个主题上找到的唯一东西是这个项目,但我宁愿使用在 .net 中可以找到的东西: http://www.codeproject.com/KB/security/PrivateEncryption.aspx

Please note I am not looking for signing.请注意,我不是在寻找签名。

Please note I require asymmetric encryption.请注意我需要非对称加密。

Any idea's?有任何想法吗?

Background story:背景故事:

I am sending an encrypted file to another system which is running an application.我正在将加密文件发送到另一个正在运行应用程序的系统。 The encryption is making sure the file cannot be altered (more or less) or viewed by anyone.加密确保文件不能被任何人更改(或多或少)或查看。 The application is able to decrypt the file using the public key and do something with it.该应用程序能够使用公钥解密文件并对其进行处理。

I know pretty much anyone is able to get the public key from the application, this is not a problem in this case.我知道几乎任何人都可以从应用程序中获取公钥,在这种情况下这不是问题。

The encryption is making sure the file cannot be altered or viewed by anyone加密确保文件不能被任何人更改或查看

Public Key Encryption - when done "by the book" - seperates encryption and signing ("cannot be altered").公钥加密——当“按规定”完成时——将加密和签名分开(“不能更改”)。 In your case, use two key pairs, one within the application and one at your site.在您的情况下,使用两个密钥对,一个在应用程序内,一个在您的站点。 Encrypt the file using the public application key and sign the file using your private one.使用公共应用程序密钥加密文件并使用您的私人密钥对文件进行签名。

This is a really widespread usage, I even like to call it "Best practice".这是一个非常普遍的用法,我什至喜欢称其为“最佳实践”。 As for the downvote, I can only guess that ruling out signing in your question triggered this.至于否决票,我只能猜测排除在您的问题上签名会触发此问题。

It should not be done.不应该这样做。 Sign instead and use symmetric encryption.改为签名并使用对称加密。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM