【问题标题】:pyinstaller: include keyring module?pyinstaller:包括密钥环模块?
【发布时间】:2015-11-11 22:46:40
【问题描述】:

我编写了一个小型 python 应用程序,使用 keyring 模块(用于将密码存储在 Windows 凭据库中)和 wxpython 用于登录 gui,自动将用户登录到特定服务。 此服务的登录工具不支持存储登录凭据,但有一个我在脚本中使用的 cmd 登录方法。

脚本现在已经完成并且运行良好,但我想将它作为 exe 部署到其他几个系统。

Keyring 似乎无法与 pyinstaller 配合使用,但在添加大量隐藏导入后,我至少可以启动我的程序:

'json', 
'json.decoder', 
'json.encoder', 
'json.scanner',
'keyring.backends.file',
'keyring.backends.Gnome',
'keyring.backends.Google',
'keyring.backends.keyczar',
'keyring.backends.kwallet',
'keyring.backends.multi',
'keyring.backends.OS_X',
'keyring.backends.pyfs',
'keyring.backends.SecretService',
'keyring.backends.Windows',
'keyring.backends._win_crypto',
'keyring.util.escape',
'keyring.util.XDG',
'keyring.credentials'

有了这些,应用程序启动时没有任何缺少模块的错误,但在尝试访问凭证库时仍然崩溃:

c:\PY\novell_login>dist\thread_test\thread_test.exe
Logging in User: test
Traceback (most recent call last):
  File "c:\PY\build\thread_test\out00-PYZ.pyz\wx._core", line 16766, in <lambda>
  File "<string>", line 119, in LongTaskDone
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.core", line 44, in set_password
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.backends.file", line 87, in set_password
  File "c:\PY\build\thread_test\out00-PYZ.pyz\keyring.backends.Windows", line 81, in encrypt
NameError: global name '_win_crypto' is not defined

我不知道还能做些什么来解决这个问题...... 任何人都可以帮助我正确包含密钥环或知道我可以使用的替代方法。我真的很想继续使用 windows crendential vault 来存储密码。

谢谢!

Python:2.7.9 安装程序:2.1 钥匙圈:5.6 pywin:构建 219

【问题讨论】:

    标签: python python-2.7 pyinstaller python-keyring


    【解决方案1】:

    即使在此处和 pyinstaller github 上发布后一周都没有成功,我制定了自己的解决方案。 我放弃了密钥环模块并使用 win32crypt 模块来使用 Windows 功能 CryptProtectData,经过一些研究,它使用与密钥环相同的保护。

    我将密码散列到存储在用户 appdata 文件夹中的字符串中,并在需要时对其进行解密。这很好用,并且应该与密钥环方法一样安全,因为它只能从同一用户处解密,重置密码以获取访问权限也不起作用。对我来说足够安全。

    当然,这适用于 pyinstaller。

    【讨论】:

      猜你喜欢
      • 2023-03-25
      • 2018-12-22
      • 1970-01-01
      • 2020-04-02
      • 2018-04-19
      • 1970-01-01
      • 2021-12-05
      • 2013-11-20
      • 2012-02-25
      相关资源
      最近更新 更多