Audio Steganography

Hide secret messages or binary data within audio signals so that casual listeners hear only the original sound.

Three methods are provided:

Method

Capacity

Audibility

Robustness

Requirement

LSB (STEG_LSB)

~1 bit/sample (~16 KB per 3 s at 44.1 kHz)

Inaudible (≈ −90 dB)

Fragile (destroyed by lossy compression)

Any sample rate

Frequency-band (STEG_FREQ_BAND)

~2.6 kbit/s (~121 bytes per 3 s at 44.1 kHz)

Above most listeners’ hearing range

Moderate (survives mild noise)

sample_rate ≥ 40 kHz

Spectrogram text (STEG_SPECTEXT)

~1 bit/sample (same as LSB)

Audible as buzzy tones; visually readable in spectrogram

Fragile (same as LSB)

Any sample rate

All methods prepend a 32-bit length header so the decoder can recover the message without knowing its length in advance.

pyminidsp.steg_capacity(signal_len, sample_rate, method=0)[source]

Compute maximum message length that can be hidden.

Compute the maximum message length (in bytes) that can be hidden.

Parameters:
Return type:

int

pyminidsp.steg_encode(host, message, sample_rate=44100.0, method=0)[source]

Encode a secret text message into a host audio signal.

Parameters:
  • host (ArrayLike) – Host signal (not modified).

  • message (str) – String message to hide.

  • sample_rate (float) – Sample rate in Hz.

  • method (int) – STEG_LSB or STEG_FREQ_BAND.

Returns:

(stego_signal, num_bytes_encoded) tuple.

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], int]

Encode a secret text message into a host audio signal.

  • LSB — flips the least-significant bit of a 16-bit PCM representation. Distortion ≈ −90 dB.

  • Frequency-band — adds a low-amplitude BFSK tone in the near-ultrasonic band (18.5 / 19.5 kHz).

  • Spectrogram text — hybrid LSB encoding that also renders the message as readable text in a spectrogram view.

Parameters:
Returns:

(stego_signal, num_bytes_encoded) tuple.

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], int]

host = md.sine_wave(44100, amplitude=0.8, freq=440.0, sample_rate=44100.0)
stego, n = md.steg_encode(host, "secret", sample_rate=44100.0, method=md.STEG_LSB)
pyminidsp.steg_decode(stego, sample_rate=44100.0, method=0, max_msg_len=4096)[source]

Decode a secret text message from a stego audio signal.

Returns:

Decoded string message.

Parameters:
  • stego (ArrayLike)

  • sample_rate (float)

  • method (int)

  • max_msg_len (int)

Return type:

str

Decode a secret text message from a stego audio signal.

Returns:

Decoded string message (empty string if none found).

Parameters:
  • stego (ArrayLike)

  • sample_rate (float)

  • method (int)

  • max_msg_len (int)

Return type:

str

pyminidsp.steg_encode_bytes(host, data, sample_rate=44100.0, method=0)[source]

Encode arbitrary binary data into a host audio signal.

Parameters:
  • host (ArrayLike) – Host signal.

  • data (bytes) – bytes-like object to hide.

  • sample_rate (float) – Sample rate in Hz.

  • method (int) – STEG_LSB or STEG_FREQ_BAND.

Returns:

(stego_signal, num_bytes_encoded) tuple.

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], int]

Encode arbitrary binary data (may contain null bytes — e.g. images, compressed archives, cryptographic keys).

Parameters:
Returns:

(stego_signal, num_bytes_encoded) tuple.

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], int]

pyminidsp.steg_decode_bytes(stego, sample_rate=44100.0, method=0, max_len=4096)[source]

Decode binary data from a stego audio signal.

Returns:

bytes object containing the decoded data.

Parameters:
  • stego (ArrayLike)

  • sample_rate (float)

  • method (int)

  • max_len (int)

Return type:

bytes

Decode binary data from a stego audio signal.

Returns:

bytes object containing the decoded data.

Parameters:
  • stego (ArrayLike)

  • sample_rate (float)

  • method (int)

  • max_len (int)

Return type:

bytes

pyminidsp.steg_detect(signal, sample_rate=44100.0)[source]

Detect which steganography method was used.

Returns:

(method, payload_type) tuple, or (None, None) if no steg detected. method is STEG_LSB, STEG_FREQ_BAND, or None. payload_type is STEG_TYPE_TEXT, STEG_TYPE_BINARY, or None.

Parameters:
  • signal (ArrayLike)

  • sample_rate (float)

Return type:

tuple[int | None, int | None]

Detect which steganography method (if any) was used.

Probes the signal for a valid header using all three methods (LSB, frequency-band, and spectrogram text). If multiple appear valid, frequency-band is preferred (lower false-positive rate).

Returns:

(method, payload_type) tuple, or (None, None) if no steganographic content is detected.

Parameters:
  • signal (ArrayLike)

  • sample_rate (float)

Return type:

tuple[int | None, int | None]