pex.string

Submodules

Package Contents

class pex.string.String

Bases: object

Main class of pex.string module.

This main class of pex.string module is intended for providing implementations of some string features and methods.

static extract_strings(binary_data: str) list

Extract strings from binary data.

Parameters:

binary_data (str) – data to extract strings from

Return list:

list of extracted strings

static xor_string(string: str) str

Perform XOR encryption on a string.

Parameters:

string (str) – string to perform XOR encryption on

Return str:

XOR encrypted string

static xor_key_string(string: str, key: str) str

Perform key XOR encryption on a string.

Parameters:
  • string (str) – string to perform key XOR encryption on

  • key (str) – key to encrypt with

Return str:

key XOR encrypted string

static xor_key_bytes(buffer: bytes, key: bytes) bytes

Perform key XOR encryption on a bytes buffer.

Parameters:
  • buffer (bytes) – buffer to perform key XOR encryption on

  • key (bytes) – key to encrypt with

Return bytes:

key XOR encrypted buffer

static base64_decode(string: str, decode: bool = True) str | bytes

Decode base64 encoded string.

Parameters:
  • string (str) – base64 encoded string to decode

  • decode (bool) – decode the result from bytes to str or not

Return Union[str, bytes]:

decoded result in type depending on decode param

static base64_string(string: str | bytes, decode: bool = True) str | bytes

Encode string with base64.

Parameters:
  • string (Union[str, bytes]) – string or bytes to encode with base64

  • decode (bool) – decode the result from bytes to str or not

Return Union[str, bytes]:

decoded result in type depending on decode param

static random_string(length: int = 16, alphabet: list = string.ascii_letters + string.digits) str

Generated random string with specified length.

Parameters:
  • length (int) – length of a generated string

  • alphabet (list) – string alphabet to generate from

Return str:

generated string

static lzs_decompress(data: bytes, window: ring_list.RingList = RingList(2048)) tuple

Decompress LZS compressed data.

Parameters:
  • data (bytes) – LZS compressed data to decompress

  • window (RingList) – RingList list

Return tuple:

decompressed data and RingList