python-3.x - TypeError:from_buffer() 无法返回 unicode 对象的地址
问题描述
在将工具更新到 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
还是不行。有人遇到过类似的问题吗?
解决方案
推荐阅读
- c# - 在按钮单击时切换到动态创建的 TabPage
- android - 当另一个应用程序发送“打开文件”意图时,如何让我的 FileProvider 提供文件?
- c# - ASP.Net Core 2.1 Web Api 2 和 Active Directory 凭证
- javascript - 亚马逊支付与 Javascript 和 PHP 的集成 - PaymentPlanNotSet
- java - 如何使用 Java 准备要在 Excel 中导入的带有双引号、制表符和双引号的 .txt
- amazon-web-services - Powershell 中的用户数据 - 无法更改附加的卷权限
- reactjs - 从父组件发起事件到子组件
- mysql - MySQL 查询以获取按月分组的最近 12 个月数据,包括零计数
- php - php REST - 防止在浏览器中直接访问
- 3d - 3D 坐标系变换