6

Trying to install py-bcrypt on win7. Python is 64bit. First error unable to find vcvarsall.bat. Googled a bit learned that i needed to install mingw. installed it now this

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

no idea what to do next. guess i'll just not use bcrypt and try something else. Any other suggestions?

pocorschi
  • 3,605
  • 5
  • 26
  • 35

7 Answers7

8

There is a compiled version of py-bcrypt for windows. You can visit https://bitbucket.org/alexandrul/py-bcrypt/downloads to download the .exe file and install.

Yang
  • 204
  • 2
  • 9
3

I stumbled upon this rather old thread while trying to get py-bcrypt installed (via pip) on Windows 7 using VS2012. Apparently, this still doesn't work (I also get the "missing vcvars.bat" error).

There is a dedicated Windows fork for py-bcrypt called py-bcrypt-w32, which I could install without any problems using

pip install py-bcrypt-w32
MartinStettner
  • 28,719
  • 15
  • 79
  • 106
  • IMO this should be the accepted answer. Just use py-bcrypt-w32 vs py-bcrypt for dev on windows with two different requirements.txt files for each environment. – Chockomonkey Jul 11 '17 at 19:27
3

I've looked at the bcrypt source, and can't figure out why you're getting the error you are (don't have a Windows system at hand to test on right now). Though looking at the pybcrypt issue tracker it looks like it has other Windows compilation problems, so it's probably not just you. At a guess though, adding "--std=C99" to the gcc arguments via extra_compile_args might fix at least some of the errors.

Aside from that, there are a couple of alternatives -

  • Bcryptor is another C-extension bcrypt implementation which may compile for your system.

  • Passlib is a general password hashing library. While it relies on bcryptor/pybcrypt for bcrypt support, it has builtin support for a number of other password hashes that may work for you - such as SHA512-Crypt or PBKDF2-HMAC-SHA512

  • Cryptacular is another general password hashing library. On Windows, it provides both BCrypt and PBKDF2-HMAC-SHA512 password hashes. (I'd link straight to those, but the documentation won't quite let me).

Eli Collins
  • 8,375
  • 2
  • 34
  • 38
  • I guess windows was just not cut for this :) i may just stay with simple hashlib.sha512 and thats it . more errors from bcryptor. ill try cryptacular next and that's that. – pocorschi Aug 17 '11 at 20:46
  • ok cryptacular works. it's bcrypt works. question. am i not supposed to salt bcrypt? just asking. – pocorschi Aug 17 '11 at 20:49
  • If you're following the example at the top of the Cryptacular docs, `manager.encode(password)` takes care of salt generation... you can test this by running `manager.encode("test")` twice, and you'll see the hash is different - this shows it's taking care of generating a new salt. ([this page](http://packages.python.org/passlib/lib/passlib.hash.bcrypt.html#format-algorithm) gives a brief description of the bcrypt hash string format if you're curious). – Eli Collins Aug 17 '11 at 22:20
  • Ok hold on. So i dont need to separately store the salt? the rounds and salt are stored inside the hash? – pocorschi Aug 18 '11 at 09:51
  • 1
    Yep... in fact all the password hashes in the libraries I linked to are completely self-contained, and the code handles salt generation automatically. Calling .encode() for Cryptacular / .encrypt() for Passlib does all of it for you... then just call .verify() to check the password. If you want a different number of rounds than the default, just pass that as rounds=value to when you call encode(). – Eli Collins Aug 18 '11 at 11:29
2

I had the same issue and I fixed it by applying the patch found at this link:

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

Had to apply it manually.

From that thread, the source of the problem is

According to http://groups.google.com/group/mpir-devel/msg/2c2d4cc7ec12adbb (flags defined under the various windows OS'es ,cygwins,mingw's and other's) its better to use _WIN32 instead of _MSC_VER, Together with the change from bzero to memset this compiles both under MSVC and MingW32.

Hope that helps!

Ingrid Morstrad
  • 187
  • 2
  • 11
0

I had this same problem with python 3.4.1, and none of the previous answers worked. I eventually got the Visual Studio 2010 64-bit compiler working, and hence both cryptacular and py-bcrypt installed with easy_install. See my detailed answer here: https://stackoverflow.com/a/27033824/3800244

Community
  • 1
  • 1
neRok
  • 995
  • 9
  • 21
0

It's 2016 and I have faced same issue. Download the wheel directly from https://bitbucket.org/alexandrul/py-bcrypt/downloads and then run following

pip install <whl-file>
DevC
  • 7,055
  • 9
  • 39
  • 58
0

supposing you are using mingw64, you should change _MSC_VER in _WIN32 on ifdefs into bcrypt.c, bcrypt_python.c and pybc_blf.h

sherpya
  • 4,890
  • 2
  • 34
  • 50