【问题标题】:py-bcrypt installing on win 7 64bit pythonpy-bcrypt 在 win 7 64bit python 上安装
【发布时间】:2011-10-29 03:30:57
【问题描述】:

尝试在 win7 上安装 py-bcrypt。 Python 是 64 位的。第一个错误找不到 vcvarsall.bat。谷歌了一下得知我需要安装 mingw。现在安装它这个

C:\tools\python_modules\py-bcrypt-0.2>python setup.py build -c mingw32
running build
running build_py
running build_ext
building 'bcrypt._bcrypt' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\Python27\include -Ic:\Python27\PC -c bcrypt/bcrypt_python.c -o b
d\temp.win-amd64-2.7\Release\bcrypt\bcrypt_python.o
bcrypt/bcrypt_python.c:29:26: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c:29:38: error: expected declaration specifiers or '...' before 'u_int16_t'
bcrypt/bcrypt_python.c:29:49: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c: In function 'bcrypt_encode_salt':
bcrypt/bcrypt_python.c:56:2: error: too many arguments to function 'encode_salt'
bcrypt/bcrypt_python.c:29:6: note: declared here
error: command 'gcc' failed with exit status 1

不知道下一步该做什么。猜猜我不会使用 bcrypt 并尝试其他方法。还有其他建议吗?

【问题讨论】:

    标签: python c gcc compiler-construction module


    【解决方案1】:

    现在是 2016 年,我也遇到了同样的问题。直接从https://bitbucket.org/alexandrul/py-bcrypt/downloads下载轮子,然后运行以下

    pip install <whl-file>
    

    【讨论】:

      【解决方案2】:

      我在使用 python 3.4.1 时遇到了同样的问题,之前的答案都没有奏效。我最终让 Visual Studio 2010 64 位编译器正常工作,因此使用 easy_install 安装了 cryptacular 和 py-bcrypt。在此处查看我的详细答案:https://stackoverflow.com/a/27033824/3800244

      【讨论】:

        【解决方案3】:

        我在尝试使用 VS2012 在 Windows 7 上(通过 pip)安装 py-bcrypt 时偶然发现了这个相当老的线程。显然,这仍然不起作用(我还收到“缺少 vcvars.bat”错误)。

        py-bcrypt 有一个专用的 Windows fork,名为 py-bcrypt-w32,我可以毫无问题地安装它

        pip install py-bcrypt-w32
        

        【讨论】:

        • IMO 这应该是公认的答案。只需在 windows 上使用 py-bcrypt-w32 vs py-bcrypt for dev,每个环境有两个不同的 requirements.txt 文件。
        【解决方案4】:

        有一个用于 windows 的 py-bcrypt 的编译版本。您可以访问https://bitbucket.org/alexandrul/py-bcrypt/downloads下载.exe文件并安装。

        【讨论】:

        • 知道这是否会很快达到 0.4?
        • @Joe 我刚刚添加了 0.4 个轮子。
        • @alexandrul 太棒了!谢谢!
        • 在那里找不到 .exes?
        【解决方案5】:

        我遇到了同样的问题,我通过应用此链接中的补丁修复了它:

        http://code.google.com/p/py-bcrypt/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=1

        py-bcrypt_11.patch

        必须手动应用。

        从那个线程来看,问题的根源是

        根据http://groups.google.com/group/mpir-devel/msg/2c2d4cc7ec12adbb(在各种 Windows 操作系统、cygwins、mingw 和其他操作系统下定义的标志)最好使用 _WIN32 而不是 _MSC_VER,连同从 bzero 到 memset 的更改,这可以在 MSVC 和 MingW32 下编译。

        希望有帮助!

        【讨论】:

          【解决方案6】:

          假设你使用的是mingw64,你应该把ifdefs上的_WIN32中的_MSC_VER改成bcrypt.c、bcrypt_python.c和pybc_blf.h

          【讨论】:

            【解决方案7】:

            我查看了 bcrypt 源代码,但无法弄清楚为什么会出现错误(现在手头没有要测试的 Windows 系统)。虽然看着 pybcrypt issue tracker 看起来它还有其他 Windows 编译问题,所以可能不仅仅是你。不过猜测一下,通过 extra_compile_args 将“--std=C99”添加到 gcc 参数中至少可以修复一些错误。

            除此之外,还有几个选择 -

            • Bcryptor 是另一个可以为您的系统编译的 C 扩展 bcrypt 实现。

            • Passlib 是一个通用的密码哈希库。虽然它依赖 bcryptor/pybcrypt 来支持 bcrypt,但它内置了对许多其他可能对您有用的密码哈希的支持 - 例如 SHA512-CryptPBKDF2-HMAC-SHA512

            • Cryptacular 是另一个通用密码哈希库。在 Windows 上,它提供 BCrypt 和 PBKDF2-HMAC-SHA512 密码哈希。 (我会直接链接到这些,但文档不会让我这样做)

            【讨论】:

            • 我猜windows并没有为此剪裁:)我可能只使用简单的hashlib.sha512,仅此而已。来自 bcryptor 的更多错误。接下来我试试cryptacular,就是这样。
            • 好的密码作品。这是 bcrypt 的作品。题。我不应该给 bcrypt 加盐吗?只是问问。
            • 如果您遵循 Cryptacular 文档顶部的示例,manager.encode(password) 负责生成盐...您可以通过运行 manager.encode("test") 两次来测试它,您会看到哈希是不同的——这表明它正在处理生成新的盐。 (如果您好奇,this page 会简要描述 bcrypt 哈希字符串格式)。
            • 好的,等等。所以我不需要单独储存盐吗?轮数和盐存储在哈希中?
            • 是的......事实上,我链接到的库中的所有密码哈希都是完全独立的,并且代码会自动处理盐生成。为 Cryptacular 调用 .encode() /为 Passlib 调用 .encrypt() 为您完成所有这一切……然后只需调用 .verify() 来检查密码。如果您想要与默认值不同的轮数,只需将其作为 rounds=value 传递给您调用 encode() 时。
            猜你喜欢
            • 1970-01-01
            • 2011-11-05
            • 2020-08-14
            • 2015-08-23
            • 1970-01-01
            • 2012-03-10
            • 1970-01-01
            • 2013-05-19
            • 2013-01-23
            相关资源
            最近更新 更多