2

我正在使用带有 openssl 的 PHP 5.3 来成功生成一对公钥和私钥。

假设有人只给我一个公钥。

如何验证此公钥是否属于我拥有的私钥?(仅通过拥有公钥和私钥,无需额外数据)

4

1 回答 1

4

Encrypt a message with the public key and see if you can decrypt it with the private key.

Alternatively, you could just extract the public key from your private key file and compare it to the public key that someone passed to you. Keys are generated in pairs, so for a given private key, the public key will always be the same.

于 2013-09-19T12:36:52.203 回答