1

我有一个向我发送加密消息的服务器。
此消息使用服务器的私钥加密,我正在尝试使用公钥对其进行解密。
verify 方法不符合我的需要,因为它返回 true 或 false。

我发现 OpenSSL 有一个名为 openssl_public_decrypt 的方法。
我尝试使用 OpenSSL .Net 包装器并没有设法让它工作。

所以我在这里问是否有另一个库可以用公钥解密并返回解密的消息,比如 OpenSSL 的?

提前致谢 !

4

2 回答 2

0

Private key is usually intended for decryption, but in the situation you described, another approach is used. Server decrypts data with private key, and then sends it to the client. That way, when client encrypts the received message with public key, it gets the original data.

If you are developing server and client, you should try this approach. And if the server belongs to someone else, they probably use it already.

As for implementation, you can try built-in .Net classes for assymetric encryption. Assuming server uses RSA algorithm for encryption, you can use RSACryptoServiceProvider class.

于 2013-04-21T19:16:24.880 回答
0

如果你想自己做加密,你可能想看看这里 https://stackoverflow.com/a/15706744/706119

我为另一个问题写了这个,但你可能可以在你的场景中使用它

这是一个使用 Bigint 的小型 RSA 实现......你必须自己处理填充,但你可以用这种方式解密......

于 2013-04-21T20:40:13.823 回答