【发布时间】:2017-07-18 05:37:05
【问题描述】:
我正在尝试在 python 中实现 sha-3。下面给出的代码是我实现它的方式。但是我一次又一次地收到以下错误。
import sys
import hashlib
arg1 = sys.argv[1]
with open(arg1, 'r') as myfile:
data=myfile.read().replace('\n', '')
import sha3
s=hashlib.sha3_228(data.encode('utf-8')).hexdigest()
print(s)
以下错误是我执行时得到的。
Traceback (most recent call last):
File "sha3.py", line 6, in <module>
import sha3
File "/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
【问题讨论】:
-
您正在尝试使用它,而不是实现它。实现意味着编写执行实际哈希计算的代码。这不是你在这里做的。