Skip to content

使用OpenSSL生成RSA秘钥对并对文件加解密

生成RSA私钥

shell
openssl genrsa -out rsa.key 1024

生成RSA公钥

shell
openssl rsa -in rsa.key -pubout -out pub.key

创建明文文件

shell
echo "This is plain message 2019-10-17" > plain.text

加密

shell
openssl rsautl -encrypt -inkey pub.key -pubin -in plain.text -out cipher.txt

解密

shell
openssl rsautl -decrypt -inkey rsa.key -in cipher.txt -out plain2.txt

https://www.cnblogs.com/xdyixia/p/11690694.html