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加密技术来保护文件的安全。通过创建密文文件并利用公钥进行加密,确保数据传输过程中的安全性;同时利用私钥进行解密,确保只有持有正确私钥的人才能读取原始信息。
1900

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



