python中的Hashlib不受支持的Hash Type Ripemd160
经过彻底的搜索,我在整个网络上都找不到解决这个非常常见问题的完整解释和解决方案。所有需要用Hashlib编码的脚本给我错误:
python 3.10
import hashlib
h = hashlib.new('ripemd160')
返回:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/usr/lib/python3.10/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type ripemd160
我已经尝试检查库中是否存在哈希,如果我有:
print(hashlib.algorithms_available) )
:{'md5','sm3','sha3_512','sha384','sha256','sha1','shake_128','sha224','sha512_224' ,'ripemd160','md5-sha1','sha512','sha3_256','shake_256','sha3_384','sha3_384','whirlpool'','sha3_24','md4','sha3_224'},'sha3_224'}
我在带有Linux的VPS中遇到了这个问题,但是在我的PC中,我使用Windows,但没有这个问题。
我衷心感谢任何帮助或建议。
After a thorough search, I have not found a complete explanation and solution to this very common problem on the entire web. All scripts that need to encode with hashlib give me error:
Python 3.10
import hashlib
h = hashlib.new('ripemd160')
return:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/usr/lib/python3.10/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type ripemd160
I already tried to check if that hash exists in the library, and if I have it:
print(hashlib.algorithms_available)
: {'md5', 'sm3', 'sha3_512', 'sha384', 'sha256', 'sha1', 'shake_128', 'sha224', 'sha512_224', 'sha512_256', 'blake2b', 'ripemd160', 'md5-sha1', 'sha512', 'sha3_256', 'shake_256', 'sha3_384', 'whirlpool', 'md4', 'blake2s', 'sha3_224'}
I am having this problem in a vps with linux, but in my pc I use Windows and I don't have this problem.
I sincerely appreciate any help or suggestion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Hashlib将OPENSL用于RIPEMD160,显然Openssl在2021年11月3.0版围绕3.0版围绕一些较旧的加密式Algos。所有功能仍然存在,但需要手动启用。参见 openssl github项目的第16994期,详细信息。
要快速启用它,请通过运行以下命令找到保存您的OpenSSL配置文件或符号链接的目录:
您现在可以转到目录并编辑配置文件(可能需要使用sudo):
确保配置文件包含以下行:
已测试:OpenSSL 3.0.2,Python 3.10.4,Linux Ubuntu 22.04 LTS Aarch64,我目前无法访问其他平台。
Hashlib uses OpenSSL for ripemd160 and apparently OpenSSL disabled some older crypto algos around version 3.0 in November 2021. All the functions are still there but require manual enabling. See issue 16994 of OpenSSL github project for details.
To quickly enable it, find the directory that holds your OpenSSL config file or a symlink to it, by running the below command:
You can now go to the directory and edit the config file (it may be necessary to use sudo):
Make sure that the config file contains following lines:
Tested on: OpenSSL 3.0.2, Python 3.10.4, Linux Ubuntu 22.04 LTS aarch64, I have no access to other platforms at the moment.