且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

openssl/RSA-使用公钥解密

更新时间:2023-01-18 09:59:29

假设您已使用openssl genrsa生成了公共和私有RSA密钥:

Let's assume you have generated a public and private RSA key using openssl genrsa:

$ openssl genrsa -out mykey
Generating RSA private key, 512 bit long modulus
...++++++++++++
..........++++++++++++
e is 65537 (0x10001)
$ openssl rsa -in mykey -pubout -out mykey.pub
writing RSA key

您可以使用如下私钥签名:

You can sign something with the private key like this:

$ md5sum myfile | openssl rsautl -inkey mykey -sign > checksum.signed

您可以使用公钥验证此数据:

You can verify this data using the public key:

$ openssl rsautl -inkey mykey.pub -pubin -in checksum.signed
df713741d8e92b15977ccd6e019730a5  myfile

这是您要找的吗?