非对称加密RSA

生成长度为1024位的RSA私钥
openssl genrsa -out rsa_private_key.pem 1024
通过RSA私钥生成RSA公钥
openssl rsa -in rsa_private_key.pem -pubout -out public.pem


使用RSA公钥加密文件
openssl rsautl -encrypt -in test -inkey public.pem -pubin -out test.de
使用RSA私钥解密文件
openssl rsautl -decrypt -in test.de -inkey private.pem -out test.out


用rsa私钥签名文件
openssl dgst -sha1 -sign private.pem -out sha1 test
用rsa公钥验证签名
openssl dgst -sha1 -verify public.pem -signature sha1 test
签名和验签原理
使用摘要算法对文件 F 提取摘要,用私钥对摘要进行加密得到了签名数据 A,将F和A一起发送个对方
接收方使用相同的摘要算法对 F 提取摘要得到C1,使用公钥对 A 进行解密得到C2,如果C1=C2,验证通过

生成RSA证书
openssl req -new -key private.pem -out abc.csr

原文地址:https://www.cnblogs.com/codeAB/p/12443083.html