前言
附上openssl的文档:openssl文档
一、编程要求
-
创建一个内容为 GuetPython的明文文件hello.txt
-
使用genrsa产生1024bit的明文rsa私钥privacy.pem,即没有加密过的私钥
-
使用rsa输出公钥文件public.pem
-
使用公钥文件public.pem加密hello.txt为hello.en
-
使用私钥privacy.pem解密hello.en为hello.de
-
测试文件会使用cat命令输出hello.de的内容检查是否正确解密
2.代码
代码如下:
echo GuetPython >hello.txt
openssl genrsa -out privacy.pem 1024
openssl rsa -in privacy.pem -pubout -out public.pem
openssl rsautl -encrypt -pubin -inkey public.pem -in hello.txt -out hello.en
openssl rsautl -decrypt -inkey privacy.pem -in hello.en -out hello.de