Skip to content

HideTXTinWAVwithCipher

stegobox.codec.HideTXTinWAVwithCipher

Bases: BaseCodec

Audio Steganography is the art of covertly embedding secret messages into digital audio. This Program lets you hide data file within a WAV Audio File. It also uses password based encryption so that anyone without the key cannot extract the data. Fernet Encrytion has been used to encrypt the data. Fernet guarantees that a message encrypted using it cannot be manipulated or read without the key.

  • Created by: QiuYu
  • Created time: 2022/11/18

Originally implemented in Rud09/SteganoSound-Py

Source code in stegobox/codec/hide_txtinwav_withcipher/hide_txtinwav_withcipher.py
class HideTXTinWAVwithCipher(BaseCodec):
    """Audio Steganography is the art of covertly embedding secret messages into
    digital audio. This Program lets you hide data file within a WAV Audio File.
    It also uses password based encryption so that anyone without the key cannot
    extract the data. Fernet Encrytion has been used to encrypt the data. Fernet
    guarantees that a message encrypted using it cannot be manipulated or read
    without the key.

    * Created by: QiuYu
    * Created time: 2022/11/18

    Originally implemented in
    [Rud09/SteganoSound-Py](https://github.com/Rud09/SteganoSound-Py)
    """

    def __init__(self) -> None:
        super().__init__()

    def encode(self, _):
        raise NotImplementedError("Please enter your password!")

    def decode(self, _):
        raise NotImplementedError("This codec does not support decoding without length")

    def encode_with_password(
        self, carrier: wave.Wave_read, payload: bytes, password: str
    ) -> tuple[bytes, wave._wave_params]:
        """Encoder requires carrier audio to be WAV and payload to be a txt file.

        Args:
            carrier: Carrier audio in format WAV. Read with 'stegobox.io.audio.read()'.
            payload: Payload (secret message) to be encoded.Payload in format txt. Read
                with `stegobox.io.txt.read()`.
            password: The users provide their password.

        Returns:
            Encoded audio in format wav with the payload embeded.
        """
        container, params = em.embed(carrier, payload, password)
        return container, params

    def decode_with_password(self, carrier: wave.Wave_read, password: str) -> bytes:
        """Decode the secret payload from the carrier audio.

        Args:
            carrier: Encoded carrier audio.
            password: The users provide their password.

        Returns:
            The decoded payload (secret message).
        """
        data = ex.extract(carrier, password)
        return data

encode_with_password(carrier, payload, password)

Encoder requires carrier audio to be WAV and payload to be a txt file.

Parameters:

Name Type Description Default
carrier Wave_read

Carrier audio in format WAV. Read with 'stegobox.io.audio.read()'.

required
payload bytes

Payload (secret message) to be encoded.Payload in format txt. Read with stegobox.io.txt.read().

required
password str

The users provide their password.

required

Returns:

Type Description
tuple[bytes, _wave_params]

Encoded audio in format wav with the payload embeded.

Source code in stegobox/codec/hide_txtinwav_withcipher/hide_txtinwav_withcipher.py
def encode_with_password(
    self, carrier: wave.Wave_read, payload: bytes, password: str
) -> tuple[bytes, wave._wave_params]:
    """Encoder requires carrier audio to be WAV and payload to be a txt file.

    Args:
        carrier: Carrier audio in format WAV. Read with 'stegobox.io.audio.read()'.
        payload: Payload (secret message) to be encoded.Payload in format txt. Read
            with `stegobox.io.txt.read()`.
        password: The users provide their password.

    Returns:
        Encoded audio in format wav with the payload embeded.
    """
    container, params = em.embed(carrier, payload, password)
    return container, params

decode_with_password(carrier, password)

Decode the secret payload from the carrier audio.

Parameters:

Name Type Description Default
carrier Wave_read

Encoded carrier audio.

required
password str

The users provide their password.

required

Returns:

Type Description
bytes

The decoded payload (secret message).

Source code in stegobox/codec/hide_txtinwav_withcipher/hide_txtinwav_withcipher.py
def decode_with_password(self, carrier: wave.Wave_read, password: str) -> bytes:
    """Decode the secret payload from the carrier audio.

    Args:
        carrier: Encoded carrier audio.
        password: The users provide their password.

    Returns:
        The decoded payload (secret message).
    """
    data = ex.extract(carrier, password)
    return data