非对称加密和解密 [英] Asymmetric Encryption and Decryption

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

问题描述

让我们说我使用这个网站上的算法,用公钥加密和解密数据:

Let us say that I use the algorithm on this site to encrypt and decrypt data with public-private keys:

C#.NET中的公钥RSA加密对CodeProject的支持

Public Key RSA Encryption in C# .NET on CodeProject

现在,让我们说有人使用我的公共密钥使用另一种算法加密他的数据,并发送给我。使用不同的算法(如网站上的一个),我能够使用我的私钥解密信息吗?或者这是不可能的,因为算法不同?

Now, let us say that someone encrypts his data using my public key using another algorithm and sends it to me. Using a different algorithm (like the one on the site), will I be able to decrypt the information back using my private key? Or is this impossible since the algorithms were different?

我的观点是,如果使用不同的加密算法,最终结果总是相同的,假设所使用的密钥是正确的?

My point is, will the end result always be the same if different encryption algorithms are used, assuming that the keys used are correct?

有没有一些标准的方法来加密信息,使其可以在不同的机器,可能不同的编程语言之间解密?

Is there some standard way to encrypt information to make it decryptable across different machines, maybe different programming languages?

推荐答案

有点讨论,但这里是我谦卑的尝试来回答问题:

A bit of discussion going, but here is my humble attempt to answer the questions:


使用不同的算法(如网站上的那个),我能否使用我的私钥解密信息?或者这是不可能的,因为算法是不同的?

Using a different algorithm (like the one on the site), will I be able to decrypt the information back using my private key? Or is this impossible since the algorithms were different?

你最肯定不会数据。一般来说,你需要一个完全匹配的算法和键。但是可以不同的是:用于加密/解密的平台,操作系统,硬件,语言或程序。这是因为一个算法作为一个公共契约与良好定义的规范和实现可以不同,只要所有的公共API渲染相同的结果。

You most certainly will not be able to decrypt the data. Generally, you need a full match for the algorithm and keys. What can be different however are: platforms, OSs, hardware, languages or programs used to encrypt/decrypt. This is because an algorithm acts as a public contract with well-defined spec and implementation can be different as long as all the public API render the same result.


我的观点是,如果使用不同的加密算法,最终结果总是相同的,假设所使用的密钥是正确的? / p>

My point is, will the end result always be the same if different encryption algorithms are used, assuming that the keys used are correct?

几乎每次这些都会有不同的结果(说几乎,我只是不知道任何这样的算法)。

Nearly every time these will be different results (saying nearly, I am just unaware of any such algorithms). You need to have full match for algorithm and required keys.


有一些标准方法来加密信息,使其可以在不同的机器之间进行解密,也许是不同的编程语言?

Is there some standard way to encrypt information to make it decryptable across different machines, maybe different programming languages?

是RSA,例如,保持您的私钥安全并共享您的公钥。这是HTTPS首先做的。每个拥有公钥的人都可以解密用私钥加密的数据。

Yes RSA, for example, keep your private key safe and share your public key. This is what HTTPS does first. Everyone with a public key can decrypt data encrypted with private key.

或者,您可以使用AES,一个具有单个密钥的对称算法进行加密/解密。这是HTTPS第二次。假设您只在可信方之间共享密钥,则两者都可以加密和解密(但没有其他人可以,因为他们没有密钥)。

Or, you can use AES, a symmetric algorithm with a single key to encrypt/decrypt. This is what HTTPS does second. Given you share the key only between trusted parties, both can encrypt and decrypt (but no one else can, given they have no key).

这篇关于非对称加密和解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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