
import sys import hashlibarg1 = sys.argv[1]with open(arg1,'r') as myfile: data=myfile.read().replace('\n','')import sha3s=hashlib.sha3_228(data.encode('utf-8')).hexdigest()print(s) 以下错误是我执行时得到的错误.
Traceback (most recent call last):file "sha3.py",line 6,in <module>import sha3file "/home/hello/documents/SHA-3/sha3.py",line 7,in <module>s=hashlib.sha3_228(data.encode('utf-8')).hexdigest()AttributeError: 'module' object has no attribute 'sha3_228' 以下链接可供参考.
https://pypi.python.org/pypi/pysha3
您正在调用hashlib库中不存在的函数.您想从包含pysha3的模块sha3调用函数sha3_228.实际上,sha3_228不存在,存在sha3_224.
只需用sha3.sha3_224替换hashlib.sha3_228即可.
并确保已使用命令安装了pysha3
python -m pip install pysha3
这是一个例子
import sha3data='maydata's=sha3.sha3_224(data.encode('utf-8')).hexdigest()print(s)# 20faf4bf0bbb9ca9b3a47282afe713ba53c9e243bc8bdf1d670671cb 总结 以上是内存溢出为你收集整理的在python实现中的Sha-3全部内容,希望文章能够帮你解决在python实现中的Sha-3所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)