Create a file:
echo ‘This is a sekret’ >/tmp/msg.txt
Export public key:
openssl rsa -in ~/private.pem -out /tmp/public.pub -outform PEM -pubout
Encrypt file with public key (anyone can have this key):
openssl rsautl -encrypt -inkey /tmp/public.pub -pubin -in /tmp/msg.txt -out /tmp/file.enc
Decrypt the file with private key (only you should have the private key):
openssl rsautl -decrypt -inkey ~/private.pem -in /tmp/file.enc -out /tmp/decrypted.txt
Check decoded message:
cat /tmp/decrypted.txt
使用RSA加密文件
本文介绍如何使用RSA公钥加密和私钥解密的方法来保护文件的安全。首先创建包含秘密信息的文件,接着导出公钥并用其加密文件,最后使用私钥进行解密并验证内容。
1900

被折叠的 条评论
为什么被折叠?



