1.26. xor

This module provides basic support for XOR encoding and decoding operations.

1.26.1. Functions

xor_decode(data, encoding='utf-8')[source]

Decode data using the XOR algorithm. This is not suitable for encryption purposes and should only be used for light obfuscation. This function requires the key to be set as the first byte of data as done in the xor_encode() function.

Parameters:data (str) – The data to decode.
Returns:The decoded data.
Return type:str
xor_encode(data, seed_key=None, encoding='utf-8')[source]

Encode data using the XOR algorithm. This is not suitable for encryption purposes and should only be used for light obfuscation. The key is prepended to the data as the first byte which is required to be decoded py the xor_decode() function.

Parameters:
  • data (bytes) – The data to encode.
  • seed_key (int) – The optional value to use as the for XOR key.
Returns:

The encoded data.

Return type:

bytes