Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

mp3 steganography library

License

NotificationsYou must be signed in to change notification settings

tomershay100/mp3-steganography-lib

Repository files navigation

travis-cidocPyPI versionGitHub 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 insideMP3 files, extract the hidden strings fromMP3 file,clean aMP3 file from hidden strings in it and generally allows to convertMP3 files toWAV (decodingprocess) 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 capacityreversible data hiding in MP3 based on Huffman tabletransformation" (which can be foundhere). Quitesimply, the idea is to be able to hide bits by changing the selection of the used Huffman table indexes. Each frame in theMP3 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 currentMP3 frame that is decoded.
    • FrameHeader class: contains all the information about the currentMP3 frame's header is decoded.
    • FrameSideInformation class: contains all the information about the currentMP3 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 theMETADATA 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 likemathematical calculations and bit operations.
    • Decoder class: consolidates theMP3 decoding process. Receives paths to files and takescare of the decoding process while printing information, creating files and analyzing theMETADATA.
  2. encoder package:
    • WAVReader class: contains all the information about theWAV 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 likemathematical calculations and bit operations.
    • Encoder class: consolidates theMP3 encoding process. Receives paths to files and takescare 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 givenMP3andWAV files. The possible actions are:
    • decodeMP3 file toWAV file.
    • encodeWAV file toMP3 file.
    • hide a string in theMP3 file.
    • reveal a string hidden in theMP3 file.
    • clean aMP3 file from hidden strings that it might hide.

You can see more information about the class hierarchyinUML.

Dependencies

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

you can also see inrequirements.txt file

Running Instructions

Steganography Class API:

  • Creating Steganography object by
    frommp3stegoimportSteganographystego=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 valueTrue).
  • for encodingWAV file intoMP3 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 theWAV file.
    • output_file_path: str: file path for the outputMP3 file.
    • bitrate: int: the bitrate that is used in the encoding process (default value is320). You may use bitratefrom32Kb to420Kb in jumps of32Kb.
  • For decodingMP3 file intoWAV file you may use
    stego=Steganography(quiet=True)stego.decode_mp3_to_wav("input.mp3","output.wav")
    • input_file_path: str: file path for theMP3 file.
    • wav_file_path: str: file path for the outputWAV file (default value=input_file_path[:-4] + ".wav").
  • For hiding a string inMP3 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 inputMP3 file.
    • output_file_path: str: file path for the outputMP3 file.
    • message: str: the message to hide in the file.
    • wav_file_path: str: file path for the outputWAV 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 valueTrue).
  • For revealing a string from aMP3 file you may use
    stego=Steganography(quiet=True)stego.reveal_massage("input.mp3","results.txt")
    • input_file_path: str: file path for the inputMP3 file.
    • txt_file_path: str: file path for the hidden string to be written to.
  • For cleaningMP3 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 inputMP3 file.
    • output_file_path: str: file path for the outputMP3 file.

Installation

Install the library using:

pip install mp3stego-lib

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp