使用说明

安装

go build RSA.go

打印帮助信息

./RSA -h

Usage of RSA:

  -bs string
        密钥bit长度
  -cipf string
        密文文件名
  -plaf string
        明文文件名
  -plas string
        明文字符串
  -pukf string
        指定要生成(或使用)公钥钥文件名
  -pvkf string
        指定要生成(或使用)私钥文件名

生成密钥

./RSA -bs 2048 -pvkf privatekey.pem -pukf publickey.pem

根据已有的私钥文件生成公钥文件

./RSA -pvkf privatekey.pem -pukf publickey.pem

加密明文文件,将加密后的数据输出到指定的文件

./RSA -pukf publickey.pem -plaf example.txt -cipf example.dat

加密明文字符串,将加密后的数据输出到指定的文件

./RSA -pukf publickey.pem -plas 你好 -cipf example.dat

解密加密文件,将解密后的明文输出到指定的文件

./RSA -pvkf privatekey.pem -cipf example.dat -plaf example.txt

解密加密文件,将解密后的明文输出到屏幕

./RSA -pvkf privatekey.pem -cipf example.dat