python+加密:使用公钥加密会话密钥

发布于 2024-07-25 21:32:24 字数 61 浏览 5 评论 0原文

我想使用公钥加密会话密钥。 PGP 软件如何做到这一点? 有人可以指定Python中加密的过程或函数吗?

I want to encrypt the session key using the public key. How does the PGP software do this?
Can somebody specify the procedure or function of encryption in Python?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谜兔 2024-08-01 21:32:24

还有 PyCrypto 模块,看起来与您正在寻找的完全一样:http://www.dlitz。 net/software/pycrypto/ API 文档位于:http://www .dlitz.net/software/pycrypto/apidoc/ 以及一些不错的文档,其中包含加密/解密的基本示例:http://www.dlitz.net/software/pycrypto/doc/

我承认我没有使用过这个模块,但似乎您会使用公钥建立一个会话,然后使用它来使用 Crypto.PublicKey 对象加密/解密通道。 然后执行生成会话密钥的常规活动,并通过您拥有的任何渠道进行通信。 最后,使用会话密钥将通道切换到 Crypto.Cipher 对象。

另外,如果安全确实是一个问题,特别是在多用户或仅部分受信任的计算机上,请务必非常非常小心地获取会话密钥的值。

There's also the PyCrypto module that looks exactly like what you are looking for: http://www.dlitz.net/software/pycrypto/ the API docs are here: http://www.dlitz.net/software/pycrypto/apidoc/ and some nice docs with basic examples of encrypting/decrypting here: http://www.dlitz.net/software/pycrypto/doc/.

I'll confess I haven't used this module, but it seems like you would establish a session with a public key, then use that to encrypt/decrypt the channel with a Crypto.PublicKey object. Then do the usual activity of generating a session key, communicating that over whatever channel you have. Finally, switch the channel to a Crypto.Cipher object using the session key.

Also, be sure to be very, very careful about how you obtain the value for your session key if security is a real concern, particularly on multiuser or only partially trusted machine.

梦回旧景 2024-08-01 21:32:24

有关基本技术的背景信息,请参阅这篇文章。 这篇文章是关于一般加密的 - 有关从 Python 使用 gpg 的信息,请参阅 这个

See this post for background information about the basic technology. That post is about encryption in general - for information about using gpg from Python, see this, for example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文