Crypto 模块安装

crypto模块的目的是为了提供通用的加密和哈希算法。

AES是一种常用的对称加密算法,加解密都用同一个密钥。crypto模块提供了AES支持,但是需要自己封装好函数,便于使用

方法一:

1,到 https://www.dlitz.net/software/pycrypto/ 下载pycrypto (这里注意不是Crypto,Crypto是C++里面的算法)

2,解压zip文件后在当前目录执行 python setup.py install

方法二:

直接 pip install pycrypto

可能遇到的报错:

1,缺少 Visual C++ 环境:

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Random.OSRNG.winrandom' extension
error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27

 ----------------------------------------
 Failed building wheel for pycrypto
 Running setup.py clean for pycrypto
 Failed to build pycrypto

  • 解决办法:到 http://aka.ms/vcpython27 下载 Visual C++ 并安装

2,文件路径配置不对:

error: Unable to find vcvarsall.bat
  • 解决办法:到 D:\Python27\Lib\distutils 打开文件msvc9compiler.py,找到函数def query_vcvarsall(version, arch="x86"),在 vcvarsall = find_vcvarsall(version)的下一行添加语句

        "C:\Users\雪\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0" +"/vcvarsall.bat"  (---即自己本地安装位置下的vcvarsall.bat文件),

        如图:

猜你喜欢

转载自www.cnblogs.com/youleng/p/9037303.html