Bases: BaseCodec
Echo Data Hiding places embedded text in the cover audio by introducing an
"echo". Digital tags are defined using four major parameters of the echo: initial
amplitude, decay rate, "zero" offset, and "one" offset (offset + delta). As the
offset (delay) between the original and the echo decreases, the two signals blend.
At a certain point the truman ear hears not an original signal and an echo, but
rather a single distorted signal.
Originally implemented in
evrrn/bachelors_thesis_steganography
Source code in stegobox/codec/echo_hiding/echo_hiding.py
| class EchoHiding(BaseCodec):
"""Echo Data Hiding places embedded text in the cover audio by introducing an
"echo". Digital tags are defined using four major parameters of the echo: initial
amplitude, decay rate, "zero" offset, and "one" offset (offset + delta). As the
offset (delay) between the original and the echo decreases, the two signals blend.
At a certain point the truman ear hears not an original signal and an echo, but
rather a single distorted signal.
Originally implemented in
[evrrn/bachelors_thesis_steganography](https://github.com/evrrn/bachelors_thesis_steganography)
"""
def __init__(self) -> None:
super().__init__()
def encode(self, carrier, payload):
"""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_r()'.
payload: Secret message to be encoded. Payload in format txt. Read with
`stegobox.io.txt.read()`.
Returns:
encoded_key: Information of the echo.
encoded_audio: Encoded audio in format wav with the payload embeded.
params: Audio information.
"""
signal = Wave(carrier)
message = CoderBinaryMessage(payload)
key = CoderKey()
stegosystem = CoderSystem(signal, message, key)
encoded_key = stegosystem.create_stego()
encoded_audio, params = stegosystem.signal.create_stegoaudio(stegosystem.key)
return encoded_key, encoded_audio, params
def decode(self, _):
raise NotImplementedError("This codec does not support decoding without key")
def decode_with_key(self, carrier, key):
"""Decode the secret payload from the carrier audio.
Args:
carrier: Encoded carrier audio.
key: Information of the echo provided by the sender.
Returns:
The revealed payload (secret message).
"""
encoded_signal = Wave(carrier)
decode_message = DecoderBinaryMessage()
decode_key = DecoderKey(key)
stegosystem = DecoderSystem(encoded_signal, decode_message, decode_key)
return stegosystem.extract_stegomessage()
|
encode(carrier, payload)
Encoder requires carrier audio to be WAV and payload to be a txt file.
Parameters:
Name |
Type |
Description |
Default |
carrier |
|
Carrier audio in format WAV. Read with
'stegobox.io.audio.read_r()'.
|
required
|
payload |
|
Secret message to be encoded. Payload in format txt. Read with
stegobox.io.txt.read() .
|
required
|
Returns:
Name | Type |
Description |
encoded_key |
|
|
encoded_audio |
|
Encoded audio in format wav with the payload embeded.
|
params |
|
|
Source code in stegobox/codec/echo_hiding/echo_hiding.py
| def encode(self, carrier, payload):
"""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_r()'.
payload: Secret message to be encoded. Payload in format txt. Read with
`stegobox.io.txt.read()`.
Returns:
encoded_key: Information of the echo.
encoded_audio: Encoded audio in format wav with the payload embeded.
params: Audio information.
"""
signal = Wave(carrier)
message = CoderBinaryMessage(payload)
key = CoderKey()
stegosystem = CoderSystem(signal, message, key)
encoded_key = stegosystem.create_stego()
encoded_audio, params = stegosystem.signal.create_stegoaudio(stegosystem.key)
return encoded_key, encoded_audio, params
|
decode_with_key(carrier, key)
Decode the secret payload from the carrier audio.
Parameters:
Name |
Type |
Description |
Default |
carrier |
|
|
required
|
key |
|
Information of the echo provided by the sender.
|
required
|
Returns:
Type |
Description |
|
The revealed payload (secret message).
|
Source code in stegobox/codec/echo_hiding/echo_hiding.py
| def decode_with_key(self, carrier, key):
"""Decode the secret payload from the carrier audio.
Args:
carrier: Encoded carrier audio.
key: Information of the echo provided by the sender.
Returns:
The revealed payload (secret message).
"""
encoded_signal = Wave(carrier)
decode_message = DecoderBinaryMessage()
decode_key = DecoderKey(key)
stegosystem = DecoderSystem(encoded_signal, decode_message, decode_key)
return stegosystem.extract_stegomessage()
|