improve hash_to_hex_str performance
This commit is contained in:
parent
b8c16d8ac5
commit
8da73ad3dd
1 changed files with 4 additions and 4 deletions
|
@ -67,17 +67,17 @@ def hash160(x):
|
|||
return ripemd160(sha256(x))
|
||||
|
||||
|
||||
def hash_to_hex_str(x):
|
||||
def hash_to_hex_str(x: bytes) -> str:
|
||||
"""Convert a big-endian binary hash to displayed hex string.
|
||||
|
||||
Display form of a binary hash is reversed and converted to hex.
|
||||
"""
|
||||
return bytes(reversed(x)).hex()
|
||||
return x[::-1].hex()
|
||||
|
||||
|
||||
def hex_str_to_hash(x):
|
||||
def hex_str_to_hash(x: str) -> bytes:
|
||||
"""Convert a displayed hex string to a binary hash."""
|
||||
return bytes(reversed(hex_to_bytes(x)))
|
||||
return hex_to_bytes(x)[::-1]
|
||||
|
||||
|
||||
class Base58Error(Exception):
|
||||
|
|
Loading…
Reference in a new issue