Audio Steganography

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

Two 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

Both 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.

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

Encode a secret text message into a host audio signal.

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

  • message – String message to hide.

  • sample_rate – Sample rate in Hz.

  • method – STEG_LSB or STEG_FREQ_BAND.

Returns:

(stego_signal, num_bytes_encoded) tuple.

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).

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

  • message – String message to hide.

  • sample_rate – Sample rate in Hz.

  • methodSTEG_LSB or STEG_FREQ_BAND.

Returns:

(stego_signal, num_bytes_encoded) tuple.

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.

Decode a secret text message from a stego audio signal.

Returns:

Decoded string message (empty string if none found).

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

Encode arbitrary binary data into a host audio signal.

Parameters:
  • host – Host signal.

  • data – bytes-like object to hide.

  • sample_rate – Sample rate in Hz.

  • method – STEG_LSB or STEG_FREQ_BAND.

Returns:

(stego_signal, num_bytes_encoded) tuple.

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

Parameters:
  • host – Host signal.

  • data – Bytes-like object to hide.

  • sample_rate – Sample rate in Hz.

  • methodSTEG_LSB or STEG_FREQ_BAND.

Returns:

(stego_signal, num_bytes_encoded) tuple.

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.

Decode binary data from a stego audio signal.

Returns:

bytes object containing the decoded data.

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.

Detect which steganography method (if any) was used.

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

Returns:

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