使用openssl进行RSA加解密
一、生成RSA私钥
openssl genrsa -out private.key 1024
二、提前RSA公钥
openssl rsa -in private.key -pubout -out public.key
三、场景一:使用公钥加密,私钥解密
1、使用公钥对明文(hello)加密
openssl rsautl -encrypt -in hello -inkey public.key -pubin -out hello.en
2、使用私钥对密文(hello.en)解密
openssl rsautl -decrypt -in hello.en -inkey private.key -out hello.de
四、场景二:使用私钥加密(签名),公钥解密(验证)
1、使用私钥对明文(hello)加密
openssl rsautl -sign -in hello -inkey private.key -out hello.en
2、使用公钥对密文(hello.en)解密
openssl rsautl -verify -in hello.en -inkey public.key -pubin -out hello.de

浙公网安备 33010602011771号