我无法弄清楚“字节”方法在抱怨什么。在下面的代码中,我正在尝试为我的客户端生成身份验证密钥,但我不断收到此错误 [1]
import hmac
import hashlib
import base64
message = bytes("Message", 'utf-8') # errors here
secret = bytes("secret", 'utf-8')
signature = base64.b64encode(hmac.new(secret, message, digestmod=hashlib.sha256).digest());
print(signature)
[1]
Traceback (most recent call last):
File "API/test/auth-client.py", line 11, in <module>
message = bytes("Message", 'utf-8')
TypeError: str() takes at most 1 argument (2 given)