M2Crypto RSA.gen_key - 从 Python 代码提供密码
RSA.gen_key 函数在用于生成密钥时始终要求输入密码。有没有办法从 python 代码中向其提供密码,而不是手动输入密码?
RSA.gen_key function always asks for password when it's used to generate keys. Is there a way to feed it the password from the python code instead of typing it manually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它唯一要求输入密码的情况是当您尝试保存密钥并且选择使用密码时。只需传递“cipher=None”作为参数即可。
例如:
但正如 Heikki 所说,密钥生成不需要密码。仅当您选择使用加密时才保存。
The only time it asks for a password is if you try to save a key and you choose to use a cipher. Just pass "cipher=None" as an argument.
For example:
But as Heikki said, key generation requires no password. Only saving if you choose to use encryption.
据我所知,它不要求输入密码:
如果您不喜欢该输出,您可以提供自定义回调函数。请参阅文档和测试。
如果您的意思是在调用
save_pem()
方法,你是对的:默认会要求输入密码。但同样,您可以提供自己的回调,以编程方式提供密码。It does not ask for passwords as far as I know:
If you don't like that output, you can provide a custom callback function. See documentation and tests.
If you mean that it asks for passphrase when calling
save_pem()
method, you are right: the default will ask for password. But again, you can provide your own callback that provides the password programmatically.