【介绍】
pycrypto是用Python写的加密工具包。
This is a collection of both secure hash functions (such as SHA256 and RIPEMD160), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.).
参考:https://pypi.python.org/pypi/pycrypto
【Installation】
下载pycrypto的最新版本,地址为:
https://pypi.python.org/pypi/pycrypto
安装方法简单:you can simply run "python setup.py build" to build the package, and "python setup.py install" to install it.
但是执行python setup.py install之后,在有的windows机器上会报错,错误描述是这样的“Warning:GMP or MPIR librariy not found;Not building Crypto.PublicKey._fastmath. ”和“error: Unable to find vcvarsall.bat”。截图如下:
这是由于vcvarsall.bat is a part of MS Visual Studio. You need either VS2008 or MinGW32 to compile the sources of Windows。就是说这个源码需要vs2008进行编译才能安装,而你的机器上没有安装vs2008。
为了解决这个问题,你可以安装一个VS2008,但是安装vs2008比较费时间。一个比较好的办法就是拿一个编译好的pycrypto来进行安装。正好网上可以找到预编译的pycrypto安装文件。
地址为:http://www.voidspace.org.uk/python/modules.shtml
下载你所需要的版本,像安装其他windows应用程序一样,“下一步”“下一步”按照默认配置安装完成即可。
【Practice】
An example usage of an encryption algorithm (AES, in this case) is: