openssl进行RSA加解密

生成私钥:

openssl genrsa -out test.key 1024

生成公钥:

openssl rsa -in test.key -pubout -out test_pub.key

公钥加密:

openssl rsautl -encrypt -in hello -inkey test_pub.key -pubin -out hello.en 

注:hello是需要加密的文本文件 

说明:-in   要加密的文件

          -inkey  指定密钥

          -pubin  纯公钥文件加密

          -out  加密后的文件

解密:

openssl rsautl -decrypt -in hello.en -inkey test.key -out hello.de

说明:-in  被加密文件

          -inkey  指定私钥文件

          -out  解密后的文件