This commit is contained in:
lz_db
2025-11-16 12:31:03 +08:00
commit 0fab423a18
1451 changed files with 743213 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
from typing import Literal, Union
def int_from_hex(number: Union[str, int]) -> int:
return number if isinstance(number, int) else int(number, 16)
def int_from_bytes(
value: bytes,
byte_order: Literal["big", "little"] = "big",
signed: bool = False,
) -> int:
"""
Converts the given bytes object (parsed according to the given byte order) to an integer.
"""
return int.from_bytes(value, byteorder=byte_order, signed=signed)