![](/img/trans.png)
[英]Python 3.9.8 fails using Black and importing `typed_ast.ast3`
[英]Python 3.9.8, hashlib and 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
認為ripemd160
可用:
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
提供正確的開關、命令、環境變量會說服重新編譯工作,但我不知道是什么。
關於發生了什么的任何想法,如何解決?
所有舊的加密功能在 OpenSSL3 中仍然存在,但現在需要手動啟用。 有關詳細信息,請參閱OpenSSL github 項目的 issue 16994 。
要快速啟用它,請通過運行以下命令找到包含 OpenSSL 配置文件或符號鏈接的目錄:
openssl version -d
您現在可以進入目錄並編輯配置文件(可能需要使用 sudo):
nano openssl.cnf
確保配置文件包含以下行:
openssl_conf = openssl_init
[openssl_init]
providers = provider_sect
[provider_sect]
default = default_sect
legacy = legacy_sect
[default_sect]
activate = 1
[legacy_sect]
activate = 1
測試:OpenSSL 3.0.2、Python 3.10.4、Linux Ubuntu 22.04 LTS aarch64,目前我無法訪問其他平台。
一個不太理想的臨時解決方案是:
port activate openssl @1.1_3
port uninstall python39
port clean python39
port install -s -f python39
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.