[root@lab RSA]# openssl genrsa -out file.key 1024
Generating RSA private key, 1024 bit long modulus
.........................................++++++
.............................................++++++
e is 65537 (0x10001)
[root@lab RSA]#
[root@lab RSA]# openssl rsa -pubout -in file.key -out file.pubkey ****导出公钥
writing RSA key
[root@lab RSA]# ll
total 8
-rw-r--r-- 1 root root 887 Jun 17 17:21 file.key
-rw-r--r-- 1 root root 272 Jun 17 17:22 file.pubkey
[root@lab RSA]# cat > test
Hallo Avaya!
[root@lab RSA]# openssl rsautl -encrypt -in test -pubin -inkey file.pubkey -out test.enc ****用公钥来加密
[root@lab RSA]# vi test.enc
[root@lab RSA]# openssl rsautl -decrypt -in test.enc -inkey file.key -out test.decrypt ****用私钥来解密
[root@lab RSA]# cat test.decrypt
Hallo Avaya!