我有一个哈希字符串的简单程序。
from Crypto.Hash import SHA512
PAYLOAD = "Hello world"
def sha(message):
h = SHA512.new()
h.update(message.encode('ascii'))
return h.digest()
if __name__ == '__main__':
print(sha(PAYLOAD))
print(type(sha(PAYLOAD)))
这是输出,
b'\xb7\xf7\x83\xba\xed\x82\x97\xf0\xdb\x91tb\x18O\xf4\xf0\x8ei\xc2\xd5\xe5\xf7\x9a\x94&\x00\xf9r_X\xce\x1f)\xc1\x819\xbf\x80\xb0l\x0f\xff+\xdd4s\x84R\xec\xf4\x0cH\x8c"\xa7\xe3\xd8\x0c\xdfo\x9c\x1c\rG'
我不明白这是一个字节数组吗?抱歉,这个问题听起来很愚蠢,但我们非常感谢您的帮助。
digest()
is documented返回一个bytes
对象,而bytes
对象正是您所得到的:https://docs.python.org/3/library/stdtypes.html#bytes-objects