小智 34
另一种选择是openssl:
# generate a 2048-bit RSA key and store it in key.txt
openssl genrsa -out key.txt 2048
# encrypt "hello world" using the RSA key in key.txt
echo "hello world" | openssl rsautl -inkey key.txt -encrypt >output.bin
# decrypt the message and output to stdout
openssl rsautl -inkey key.txt -decrypt <output.bin
Run Code Online (Sandbox Code Playgroud)
Gre*_*ill 12
如果您已经gpg安装,这是一种工业强度的加密方法。
gpg --encrypt -r receiver@example.com >tempfile
在控制台输入数据并按下Ctrl+D结束文本。这将为您提供tempfile. 解密:
gpg --decrypt <临时文件
您将需要密码recipient@example.com来解密消息。
小智 7
生成私钥/公钥对
$ openssl genrsa -out rsa_key.pri 2048; openssl rsa -in rsa_key.pri -out rsa_key.pub -outform PEM -pubout
Run Code Online (Sandbox Code Playgroud)使用公钥加密字符串,并存储在文件中
$ echo "stockexchange.com" | openssl rsautl -encrypt -inkey rsa_key.pub -pubin -out secret.dat
Run Code Online (Sandbox Code Playgroud)使用私钥解密
$ string=`openssl rsautl -decrypt -inkey rsa_key.pri -in secret.dat `; echo $string
stockexchange.com
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
57284 次 |
| 最近记录: |