Skip to main content

MP3-Steganography

travis-ci doc PyPI version GitHub version

Contributes

This is a steganography library in python for hiding strings in mp3 files.

  1. General
  2. Dependencies
  3. Running Instructions
  4. Installation

General

Background

This python library allows a user to hide strings inside MP3 files, extract the hidden strings from MP3 file, clean a MP3 file from hidden strings in it and generally allows to convert MP3 files to WAV (decoding process) files and vice versa (encoding process).

Project Description

The steganography process uses and modifies the selection of the optimal (that requires the minimal amount of bits to code the data) Huffman tables as presented in the research article "High capacity reversible data hiding in MP3 based on Huffman table transformation" (which can be found here). Quite simply, the idea is to be able to hide bits by changing the selection of the used Huffman table indexes. Each frame in the MP3 file uses several Huffman tables (one per granule, channel and region - a total of 8-12 tables).

For the steganography we ordered the tables as pairs according to their similarities (from the article), and determined that each table represent the bit 0 or 1. For the sake of demonstration let us assume that the Huffman table x and the Huffman table y are a pair, and that x represents the bit 0 and y represents bit 1. To hide a bit, given that the Huffman table x has been selected as the optimal table, it is replaced with the Huffman table y if the bit is 1, otherwise the table x is selected. An inverted case will happen for original use of table y.

Project Structure

The library is contains several packages and several classes built as follows:

  1. decoder package:
    • Frame class: contains all the information about the current MP3 frame that is decoded.
    • FrameHeader class: contains all the information about the current MP3 frame's header is decoded.
    • FrameSideInformation class: contains all the information about the current MP3 frame's side-information is decoded.
    • MP3Parser class: performs the decoding process while parsing the frames of the file.
    • ID3Parser class: performs the decoding process on the METADATA of the ``MP3``` file.
    • tables file: contains all the tables that are used in the decoding process.
    • util file: contains all the different functions and dataclasses that other classes use frequently like mathematical calculations and bit operations.
    • Decoder class: consolidates the MP3 decoding process. Receives paths to files and takes care of the decoding process while printing information, creating files and analyzing the METADATA.
  2. encoder package:
    • WAVReader class: contains all the information about the WAV file that is encoded.
    • MP3Encoder class: performs the encoding process.
    • tables file: contains all the tables that are used in the encoding process.
    • util file: contains all the different functions and dataclasses that other classes use frequently like mathematical calculations and bit operations.
    • Encoder class: consolidates the MP3 encoding process. Receives paths to files and takes care of the encoding process while printing information, creating files.
  3. Steganography class: serves as a kind of Façade and allows the user to perform operations on given MP3 and WAV files. The possible actions are:
    • decode MP3 file to WAV file.
    • encode WAV file to MP3 file.
    • hide a string in the MP3 file.
    • reveal a string hidden in the MP3 file.
    • clean a MP3 file from hidden strings that it might hide.

You can see more information about the class hierarchy in UML.

Dependencies

  1. Python 3.9+
  2. NumPy
  3. SciPy
  4. TQDM
  5. bitarray
  6. numba

you can also see in requirements.txt file

Running Instructions

Steganography Class API:

  • Creating Steganography object by
    from mp3stego import Steganography
    
    stego = Steganography(quiet=True)
    
    • quiet: bool: boolean value for the constructor of the Steganography class that determines if the information about the decoding/encoding process will be printed (default value True).
  • for encoding WAV file into MP3 file you may use
    stego = Steganography(quiet=True)
    stego.encode_wav_to_mp3("input.wav", "output.mp3", 320)
    
    • wav_file_path: str: file path for the WAV file.
    • output_file_path: str: file path for the output MP3 file.
    • bitrate: int: the bitrate that is used in the encoding process (default value is 320). You may use bitrate from 32Kb to 420Kb in jumps of 32Kb.
  • For decoding MP3 file into WAV file you may use
    stego = Steganography(quiet=True)
    stego.decode_mp3_to_wav("input.mp3", "output.wav")
    
    • input_file_path: str: file path for the MP3 file.
    • wav_file_path: str: file path for the output WAV file (default value=input_file_path[:-4] + ".wav").
  • For hiding a string in MP3 file you may use
    stego = Steganography(quiet=True)
    stego.hide_message("input.mp3", "output.mp3", "String to hide in the file")
    
    • input_file_path: str: file path for the input MP3 file.
    • output_file_path: str: file path for the output MP3 file.
    • message: str: the message to hide in the file.
    • wav_file_path: str: file path for the output WAV file (default value=input_file_path[:-4] + ".wav").
    • delete_wav: bool: boolean value for the decoding process that determines if the wav file that is created from the decodin process will be deleted. (default value True).
  • For revealing a string from a MP3 file you may use
    stego = Steganography(quiet=True)
    stego.reveal_massage("input.mp3", "results.txt")
    
    • input_file_path: str: file path for the input MP3 file.
    • txt_file_path: str: file path for the hidden string to be written to.
  • For cleaning MP3 file from a hidden string you may use
    stego = Steganography(quiet=True)
    stego.clear_file("input.mp3", "output.mp3")
    
    • input_file_path: str: file path for the input MP3 file.
    • output_file_path: str: file path for the output MP3 file.

Installation

Install the library using:

pip install mp3stego-lib

Metadata

Release files for mp3stego-lib 1.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mp3stego-lib 1.1.8
File Size Uploaded
mp3stego_lib-1.1.8.tar.gz 53.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mp3stego-lib 1.1.8
File Interpreter ABI Platform
mp3stego_lib-1.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 108.4 kB

Release files / mp3stego_lib-1.1.8.tar.gz

Download URL mp3stego_lib-1.1.8.tar.gz
Size 53.3 kB
Tags Source
SHA-256 checksum
How to use checksums
04476413ea94f5562c2bf46c7b64cc5d9ef708f70a0723ef397220a44340bcf6
BLAKE2b-256 checksum
How to use checksums
0221e9bc39c6375bf7751d8fd48dfcf3159696d0cca60b819c4b8a2883e72f48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / mp3stego_lib-1.1.8-py3-none-any.whl

Download URL mp3stego_lib-1.1.8-py3-none-any.whl
Size 55.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f6ad1407cfc531af6d6a75c93da4ccd192ee0112245829489d4fb95c392ea05
BLAKE2b-256 checksum
How to use checksums
c83ef732e23c8a6b2c0e14a84edca2de49fa42e9c9e0e305ba4ad77dab665d4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.1.8 This release

2 release files

1.1.7

1 release file

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.11

2 release files

0.2.10

1 release file

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

1 release file

0.2.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page