bech32_base
Module for base bech32 decoding/encoding.
- class Bech32BaseConst
Bases:
object
Class container for Bech32 constants.
- CHARSET: str = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
- class Bech32BaseUtils
Bases:
object
Class container for Bech32 utility functions.
- static ConvertToBase32(data: Union[List[int], bytes]) List[int]
Convert data to base32.
- Parameters:
data (list[int] or bytes) – Data to be converted
- Returns:
Converted data
- Return type:
list[int]
- Raises:
ValueError – If the string is not valid
- static ConvertFromBase32(data: Union[List[int], bytes]) List[int]
Convert data from base32.
- Parameters:
data (list[int] or bytes) – Data to be converted
- Returns:
Converted data
- Return type:
list[int]
- Raises:
ValueError – If the string is not valid
- static ConvertBits(data: Union[bytes, List[int]], from_bits: int, to_bits: int, pad: bool = True) Optional[List[int]]
Perform bit conversion. The function takes the input data (list of integers or byte sequence) and convert every value from the specified number of bits to the specified one. It returns a list of integer where every number is less than 2^to_bits.
- Parameters:
data (list[int] or bytes) – Data to be converted
from_bits (int) – Number of bits to start from
to_bits (int) – Number of bits to end with
pad (bool, optional) – True if data must be padded with zeros, false otherwise
- Returns:
List of converted values, None in case of errors
- Return type:
list[int]
- class Bech32EncoderBase
Bases:
ABC
Bech32 encoder base class. It provides methods for encoding to Bech32 format.
- class Bech32DecoderBase
Bases:
ABC
Bech32 decoder base class. It provides methods for decoding Bech32 format.