Spr*_*ite 8 cryptography python-3.x python-cffi python-cryptography
在将工具更新到 python3 时,我在 MacOS 上遇到了这个问题。
print(args.secret)
h = hmac.HMAC(args.secret.decode("hex"),hashes.SHA512(),backend=default_backend())
Run Code Online (Sandbox Code Playgroud)
输出
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
Run Code Online (Sandbox Code Playgroud)
可能是加密包的问题。一些答案建议重新安装加密包及其依赖项。(cffi、pycparser、六)
pip3 list
Run Code Online (Sandbox Code Playgroud)
six 1.14.0
cryptography 2.8
pycparser 2.19
cffi 1.13.2
Run Code Online (Sandbox Code Playgroud)
还是不行。有人遇到过类似的问题吗?