Skip to content

Index

πŸ€– AI-Generated Content

This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.

flavor.utils

Shared utilities: platform detection, XOR encoding, and re-exports.

Functions

xor_decode

xor_decode(data: bytes, key: bytes = XOR_KEY) -> bytes

XOR decode data with repeating key.

Since XOR is symmetric, this is the same as encoding.

Parameters:

Name Type Description Default
data bytes

Bytes to decode

required
key bytes

XOR key bytes (defaults to Ο€ digits)

XOR_KEY

Returns:

Type Description
bytes

XOR decoded bytes

Source code in flavor/utils/xor.py
def xor_decode(data: bytes, key: bytes = XOR_KEY) -> bytes:
    """
    XOR decode data with repeating key.

    Since XOR is symmetric, this is the same as encoding.

    Args:
        data: Bytes to decode
        key: XOR key bytes (defaults to Ο€ digits)

    Returns:
        XOR decoded bytes
    """
    return xor_encode(data, key)  # XOR is its own inverse

xor_encode

xor_encode(data: bytes, key: bytes = XOR_KEY) -> bytes

XOR encode data with repeating key.

Parameters:

Name Type Description Default
data bytes

Bytes to encode

required
key bytes

XOR key bytes (defaults to Ο€ digits)

XOR_KEY

Returns:

Type Description
bytes

XOR encoded bytes

Source code in flavor/utils/xor.py
def xor_encode(data: bytes, key: bytes = XOR_KEY) -> bytes:
    """
    XOR encode data with repeating key.

    Args:
        data: Bytes to encode
        key: XOR key bytes (defaults to Ο€ digits)

    Returns:
        XOR encoded bytes
    """
    n = len(data)
    if n == 0:
        return b""
    key_len = len(key)
    # Extend key to cover all data in one pass
    full_key = key * (n // key_len) + key[: n % key_len]
    # Single large-int XOR β€” zero per-chunk allocations
    data_int = int.from_bytes(data, "little")
    key_int = int.from_bytes(full_key, "little")
    result_int = data_int ^ key_int
    return result_int.to_bytes(n, "little")