0

我正在尝试在经过交叉编译以在 ARM 上运行的 python 中使用 openssl。由于某种原因,找不到 sha 散列方法。在 python 控制台中,我输入:

导入哈希库

ERROR:root:code for hash sha1 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha512

如果我再次输入,我不会收到任何错误消息。这是一个问题。但更重要的问题是,当我输入:

从 hashlib 导入 sha1 作为 sha

我收到此错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name sha1

关于应该在哪里实施 sha 的任何想法或提示?甚至 sha.py 也试图从 hashlib 中导入 sha1。

另一条信息:当我输入“dir(hashlib)”时,我得到

['__all__', '__builtins__', '__doc__', '__file__', '__get_builtin_constructor', '__name__', '__package__', 'algorithms', 'logging', 'md5', 'new']
4

0 回答 0