且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何用python加密文件,但可以使用shell解密?

更新时间:2023-02-25 18:13:15

您需要使用 openssl

我使用命令行GnuPG,有非常好的Python库: python-gnupg 。它是一个命令行 gpg 的包装,所以它们的工作原理是一样的。

I use command line GnuPG and there is very nice Python library: python-gnupg . It is a wrapper over command line gpg so they work simply the same.

它包含密码)可以使用非对称加密。为每个部分创建私钥/公钥对,然后使用收件人公钥加密邮件,并使用发件人私钥sigg。收件人将使用发件人公钥检查发件人的签名,收件人将使用她的私钥解密邮件。私钥可以通过密码保护,但如果您确定您的环境安全,您可以使用空密码。

Instead of key file (I think it contains password) you can use asymmetric cryptography. Create private/public pairs of keys for each part and then encrypt message using recipient public key and sigg it using sender private key. Recipient will check signature of sender using sender public key and recipient will decrypt message using her private key. Private keys can be protected by password but if you are sure your environments are safe you can use empty passwords.