4

在将工具更新到 python3 时,我在 MacOS 上遇到了这个问题。

print(args.secret)
h = hmac.HMAC(args.secret.decode("hex"),hashes.SHA512(),backend=default_backend())

输出

39830c786a16

h = hmac.HMAC(hex(int(args.secret, 16)), hashes.SHA512(), backend=default_backend())
  File "/usr/local/lib/python3.7/site-packages/cryptography/hazmat/primitives/hmac.py", line 31, in __init__
    self._ctx = self._backend.create_hmac_ctx(key, self.algorithm)
  File "/usr/local/lib/python3.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 202, in create_hmac_ctx
    return _HMACContext(self, key, algorithm)
  File "/usr/local/lib/python3.7/site-packages/cryptography/hazmat/backends/openssl/hmac.py", line 34, in __init__
    key_ptr = self._backend._ffi.from_buffer(key)
TypeError: from_buffer() cannot return the address of a unicode object

可能是密码学包的问题。一些答案建议重新安装加密包及其依赖项。(cffi,pycparser,六)

pip3 list
six             1.14.0
cryptography    2.8
pycparser       2.19
cffi            1.13.2

还是不行。有人遇到过类似的问题吗?

4

0 回答 0