-
Notifications
You must be signed in to change notification settings - Fork 576
Expand file tree
/
Copy path__init__.py
More file actions
32 lines (27 loc) · 777 Bytes
/
__init__.py
File metadata and controls
32 lines (27 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Fallback expressions help PyBitmessage modules to run without some external
dependencies.
RIPEMD160Hash
-------------
We need to check :mod:`hashlib` for RIPEMD-160, as it won't be available
if OpenSSL is not linked against or the linked OpenSSL has RIPEMD disabled.
Try to use `pycryptodome <https://pypi.org/project/pycryptodome/>`_
in that case.
"""
import hashlib
try:
hashlib.new('ripemd160')
except ValueError:
try:
from Crypto.Hash import RIPEMD160
except ImportError:
RIPEMD160Hash = None
else:
RIPEMD160Hash = RIPEMD160.new
else:
def RIPEMD160Hash(data=None):
"""hashlib based RIPEMD160Hash"""
hasher = hashlib.new('ripemd160')
if data:
hasher.update(data)
return hasher