RSA公私钥生成

u=130553086,3593563691&fm=26&gp=0.jpg

·1.创建加密密钥

//默认生成2048 bit 长度,可以添加 1024 bit
$openssl genrsa -out private.pem

·2.通过私钥生成公钥

$openssl rsa -in private.pem -pubout -out public.pem

·测试加密解密
·创建txt文件

$vi rsaT.txt

··私钥加密->公钥解密

//加密
$openssl rsautl -sign -in rsaT.txt  -inkey private.pem -out decRsaT.txt

//解密
$openssl rsautl -verify -in decRsaT.txt -inkey public.pem -pubin -out publicVerifyTestRsa.txt

··公钥加密->私钥解密

//加密
$openssl rsautl -encrypt -in rsaT.txt  -inkey public.pem  -pubin -out encRsaT.txt

//解密
$openssl rsautl -decrypt -in encRsaT.txt  -inkey private.pem -out decRsaT.txt

你可能感兴趣的:(RSA公私钥生成)