python-3.x - Python 3.9.8、hashlib 和 RIPEMD160
问题描述
运行 MacOS 10.14.6。刚刚运行 MacPorts 更新。使用 Python 3.9.7 -> 3.9.8 和 OpenSSL 1.1.3 -> 3。
运行现有的 Python 代码会发现有hashlib
问题,RIPEMD160 不再可用(Whirlpool 和可能的其他摘要也不再可用)。
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 160, in __hash_new
return _hashlib.new(name, data, **kwargs)
ValueError: [digital envelope routines] initialization error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testhash.py", line 3, in <module>
r160 = hashlib.new('ripemd160')
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type ripemd160
可以简单地复制
import hashlib
r160 = hashlib.new('ripemd160')
方法hashlib.algorithms_available
表明hashlib
thinksripemd160
可用:
Available: {'sha512', 'shake_128', 'ripemd160', 'sha224', 'md5', 'whirlpool', 'blake2b', 'sha3_512', 'md4', 'sha3_256', 'sha256', 'shake_256', 'md5-sha1', 'sha1', 'sha512_224', 'sm3', 'mdc2', 'blake2s', 'sha3_384', 'sha3_224', 'sha512_256', 'sha384'}
Guaranteed: {'sha3_512', 'sha512', 'sha1', 'shake_128', 'sha3_384', 'sha224', 'md5', 'sha256', 'sha3_224', 'sha3_256', 'shake_256', 'blake2b', 'blake2s', 'sha384'}
并询问openssl
确认它确实具有这种能力。
回滚,同样的问题。我宁愿保持最新的安装。RIPEMD160 的使用不可协商。
我怀疑给出ports
正确的开关、命令、环境变量会说服重新编译工作,但我不知道是什么。
关于发生了什么的任何想法,如何解决?
解决方案
一个不太理想的临时解决方案是:
- 回滚 OpenSSL
port activate openssl @1.1_3
- 删除 Python 的安装(必要时回滚到以前的版本后)
port uninstall python39
port clean python39
- 重新编译 Python
port install -s -f python39
推荐阅读
- node.js - 为 Kubernetes 部署返回未定义的环境变量
- gradle - 我该如何解决这个问题
- angular - 没有背景时,如何在外部单击时关闭垫子自定义叠加层?
- c++ - async_write 完成处理程序最早何时完成?
- c++ - 使用完数据结构后清空它们是一个好习惯吗?
- java - 有/没有 TRUNCATE_EXISTING 的 StandardOpenOption.WRITE + StandardOpenOption.CREATE 之间的区别?
- .net - SPA 角色声明和授权。.net 核心和 react.js
- amazon-web-services - 如何使用 AWS 实例连接到本地计算机上的服务器?
- reactjs - React Bootstrap 3 - FormControl.Feedback 消息传递
- flutter - 为什么flutter的Future函数会运行多次?