[pycrypto] winrandom alternative

Gregory Taylor gtaylor at duointeractive.com
Mon Aug 16 08:59:05 CST 2010


I'm not sure if this is the best place for something like this, but I figured I'd share a workaround and a suggestion for others to take or leave. I'm currently running a 64-bit Windows 7 machine for testing some of our codebase on Windows, and ran into a snag while installing PyCrypto (so I could use Fabric, which depends on Paramiko, which depends on PyCrypto). 

As you are probably aware of, PyCrypto tries to download/compile winrandom, which can be a problem for many that lack a compiler. As an alternative for those who can't/won't install winrandom, I put together a ctypes equivalent that doesn't require compilation like the original winrandom. This new module aims to be functionally equivalent in every way to winrandom, but accesses the Windows-specific cryptography library through ctypes rather than a compiled Python C extension module.

The PyPi page can be found at: http://pypi.python.org/pypi/winrandom-ctypes/
The Github page can be found at: http://github.com/duointeractive/winrandom-ctypes

I understand that going the ctypes route might raise the minimum Python version required (2.4 or 2.5?), so this probably isn't a one-size-fits-all solution. However, if there was anything that could be done to make it easier for a user to elect to use the ctypes version, that'd be great. Perhaps PyCrypto could check at install time whether winrandom is already installed, and skip trying to compile/re-install it (winrandom-ctypes provides winrandom) to allow a user to plug something else in (winrandom-ctypes?).

Just thought I'd throw this out here for those who might find it useful in the painful situation that they have to develop on Windows.

Greg Taylor
DUO Interactive, LLC

More information about the pycrypto mailing list