stegosphere.spatial module

class stegosphere.spatial.BaseLSB(obj)

Bases: BaseCoder

BaseLSB provides functionality for encoding and decoding data using Least Significant Bit (LSB) steganography.

Parameters:

obj (numpy.ndarray) – The data object (NumPy array) where the message will be encoded/decoded.

decode(matching=False, seed=None, bits=1, method='metadata', metadata_length=32, delimiter_message='###END###', compress=False)

Decodes a message from the cover data using LSB steganography.

The message can be decoded using either a delimiter, metadata, or without any end-of-message marker. It also supports optional message verification to ensure the decoded message matches the original encoded message.

Parameters:
  • matching (bool, optional) – Whether to use LSB matching (not implemented yet). Defaults to False.

  • seed (int, optional) – (Optional) Seed value for pseudo-randomly distributing the message in the cover data.

  • bits (int, optional) – Number of bits used for decoding per value. Defaults to 1.

  • method (str, optional) – Method for marking the end of the message. Options are ‘delimiter’, ‘metadata’, or None. Defaults to ‘metadata’.

  • metadata_length (int, optional) – Length of the metadata in bits when method=’metadata’. Defaults to METADATA_LENGTH_LSB.

  • delimiter_message (str, optional) – The delimiter string used when method=’delimiter’.

  • compress (bool, optional) – Whether compression was used on the encoded data. Defaults to False.

Returns:

The decoded message

Return type:

str or tuple

encode(message, matching=False, seed=None, bits=1, method='metadata', metadata_length=32, delimiter_message='###END###', compress=False)

Encodes a message into the cover data using LSB steganography.

The message can be decoded using either a delimiter, metadata, or without any end-of-message marker. It also supports optional message verification to ensure the decoded message matches the original encoded message.

Parameters:
  • message (str) – The message to be hidden. Gets converted into binary if not already.

  • matching (bool, optional) – Whether to use LSB matching (not implemented yet). Defaults to False.

  • seed (int, optional) – (Optional) Seed value for pseudo-randomly distributing the message in the cover data.

  • bits (int, optional) – Number of bits used for decoding per value. Defaults to 1.

  • method (str, optional) – Method for marking the end of the message. Options are ‘delimiter’, ‘metadata’, or None. Defaults to ‘metadata’.

  • metadata_length (int, optional) – Length of the metadata in bits when method=’metadata’. Defaults to METADATA_LENGTH_LSB.

  • delimiter_message (str, optional) – The delimiter string used when method=’delimiter’.

  • compress (bool, optional) – Whether to use compression on the input data. Defaults to False.

Raises:

NotImplementedError – If LSB matching is used.

Returns:

True, if it worked.

Return type:

bool

max_capacity(bits=1)

Calculates the maximum capacity of the cover object for embedding a message.

The capacity is determined by the size of the data array and the number of bits available for modification.

Parameters:

bits (int) – Number of bits changed per value. Defaults to 1.

Returns:

The maximum capacity of the object in bits.

Return type:

int

class stegosphere.spatial.BaseVD(obj, pos_dim=2, depth=3)

Bases: BaseCoder

BaseVD provides functionality for encoding and decoding data using Value Differencing steganography. It is an adapted and generalised version of the Pixel Value Differencing method as proposed by Wu, D. C., & Tsai, W. H. (2003). A steganographic method for images by pixel-value differencing. Pattern recognition letters, 24(9-10), 1613-1626.

Parameters:
  • obj (numpy.ndarray) – The data object (NumPy array) where the message will be encoded/decoded.

  • pos_dim (int) – number of dimensions without depth dimension

  • depth (int) – number of channels per value

decode(seed=None, method='metadata', metadata_length=32, delimiter_message='###END###', compress=False)

Decodes a message from the cover data using Value Differencing steganography.

The message can be decoded using either a delimiter, metadata, or without any end-of-message marker. It also supports optional message verification to ensure the decoded message matches the original encoded message.

Parameters:
  • seed (int, optional) – (Optional) Seed value for pseudo-randomly distributing the message in the cover data.

  • method (str, optional) – Method for marking the end of the message. Options are ‘delimiter’, ‘metadata’, or None. Defaults to ‘metadata’.

  • metadata_length (int, optional) – Length of the metadata in bits when method=’metadata’. Defaults to METADATA_LENGTH_LSB.

  • delimiter_message (str, optional) – The delimiter string used when method=’delimiter’.

Returns:

The decoded message

Return type:

str or tuple

define_range(dtype)
encode(message, seed=None, method='metadata', metadata_length=32, delimiter_message='###END###', compress=False)

Encodes a message from the cover data using Value Differencing steganography.

The message can be decoded using either a delimiter, metadata, or without any end-of-message marker. It also supports optional message verification to ensure the decoded message matches the original encoded message.

Parameters:
  • message (str) – The message to be hidden. Gets converted into binary if not already.

  • seed (int, optional) – (Optional) Seed value for pseudo-randomly distributing the message in the cover data.

  • method (str, optional) – Method for marking the end of the message. Options are ‘delimiter’, ‘metadata’, or None. Defaults to ‘metadata’.

  • metadata_length (int, optional) – Length of the metadata in bits when method=’metadata’. Defaults to METADATA_LENGTH_IMAGE.

  • delimiter_message (str, optional) – The delimiter string used when method=’delimiter’.

Returns:

True, if it worked.

Return type:

bool

max_capacity()