python hashlib模块安装__python hashlib中的sha导入

实际上,sha模块是由shamodule.c提供的,_md5是由md5module.c和md5.c提供的,只有在Python默认不是用OpenSSL编译的情况下才会构建这两个模块。在

您可以在Python源代码tarball的setup.py中找到详细信息。在if COMPILED_WITH_PYDEBUG or not have_usable_openssl:

# The _sha module implements the SHA1 hash algorithm.

exts.append( Extension('_sha', ['shamodule.c']) )

# The _md5 module implements the RSA Data Security, Inc. MD5

# Message-Digest Algorithm, described in RFC 1321. The

# necessary files md5.c and md5.h are included here.

exts.append( Extension('_md5',

sources = ['md5module.c', 'md5.c'],

depends = ['md5.h']) )

通常,Python是用Openssl库构建的,在这种情况下,这些函数是由Openssl库本身提供的。在

现在,如果您想单独使用它们,那么您可以不使用OpenSSL构建Python,或者更好,可以使用pydebug选项构建并拥有它们。在

从Python源代码tarball:

^{pr2}$

你就这样:>>> import _sha

[38571 refs]

>>> _sha.__file__

'/home/senthil/python/release27-maint/build/lib.linux-i686-2.7-pydebug/_sha.so'

[38573 refs]

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值