Class MP3Steganography

  • All Implemented Interfaces:
    Steganography

    public class MP3Steganography
    extends java.lang.Object
    implements Steganography
    This class can encode and decode messages from a byte array containing an MP3 audio file using an overlay.
    Author:
    Richard Rudek
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] decode​(byte[] steganographicData)
      Attempts to retrieve a hidden message from the given byte array (which contains an mp3 file) using the default seed.
      byte[] decode​(byte[] steganographicData, long seed)
      Attempts to retrieve a hidden message from the given byte array (which contains an mp3 file) using the given seed.
      byte[] encode​(byte[] carrier, byte[] payload)
      Conceals the given payload in the carrier (which is an mp3 file) using a default seed.
      byte[] encode​(byte[] carrier, byte[] payload, long seed)
      Conceals the given payload in the carrier (which is an mp3 file) using the given seed.
      boolean isSteganographicData​(byte[] data)
      Checks if the given byte array contains a message that was hidden using the default seed.
      boolean isSteganographicData​(byte[] data, long seed)
      Checks if the given byte array contains a message that was hidden using the given seed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MP3Steganography

        public MP3Steganography​(MP3Overlays overlay)
        Creates an instance using the MP3Overlay provided.
        Parameters:
        overlay - overlay to use
      • MP3Steganography

        public MP3Steganography()
        Creates an instance using the default overlay.
        The default is MP3Overlays.SEQUENCE_OVERLAY.
    • Method Detail

      • encode

        public byte[] encode​(byte[] carrier,
                             byte[] payload)
                      throws AudioNotFoundException,
                             AudioCapacityException,
                             java.lang.NullPointerException
        Conceals the given payload in the carrier (which is an mp3 file) using a default seed.
        Specified by:
        encode in interface Steganography
        Parameters:
        carrier - a byte array containing an mp3 file
        payload - a byte array containing the message
        Returns:
        The given carrier with the hidden message
        Throws:
        AudioNotFoundException - If the given bytes either don't contain an mp3 file or the mp3 file is not supported by this algorithm
        AudioCapacityException - If the payload does not fit into the carrier
        java.lang.NullPointerException - If the carrier and or payload are null or have length 0
      • encode

        public byte[] encode​(byte[] carrier,
                             byte[] payload,
                             long seed)
                      throws AudioNotFoundException,
                             AudioCapacityException,
                             java.lang.NullPointerException
        Conceals the given payload in the carrier (which is an mp3 file) using the given seed.
        Specified by:
        encode in interface Steganography
        Parameters:
        carrier - a byte array containing an mp3 file
        payload - a byte array containing the message
        seed - affects the resulting steganographic data (similar to a password)
        Returns:
        the given carrier with the hidden message
        Throws:
        AudioNotFoundException - If the given bytes either don't contain an mp3 file or the mp3 file is not supported by this algorithm
        AudioCapacityException - If the payload does not fit into the carrier
        java.lang.NullPointerException - If the carrier and or payload are null or have length 0
      • decode

        public byte[] decode​(byte[] steganographicData)
                      throws UnknownStegFormatException,
                             AudioNotFoundException,
                             java.lang.NullPointerException
        Attempts to retrieve a hidden message from the given byte array (which contains an mp3 file) using the default seed.
        Specified by:
        decode in interface Steganography
        Parameters:
        steganographicData - a byte array containing an mp3 file that has a message hidden within
        Returns:
        a byte array containing the hidden message
        Throws:
        UnknownStegFormatException - if the message could not be read from the given byte array. This can happen if the file got changed after encoding (e.g. file gets compressed when uploading it to a social media).
        AudioNotFoundException - If the given bytes either don't contain an mp3 file or the mp3 file is not supported by this algorithm
        java.lang.NullPointerException - If the given byte array is null or has length 0
      • decode

        public byte[] decode​(byte[] steganographicData,
                             long seed)
                      throws UnknownStegFormatException,
                             AudioNotFoundException,
                             java.lang.NullPointerException
        Attempts to retrieve a hidden message from the given byte array (which contains an mp3 file) using the given seed.
        Specified by:
        decode in interface Steganography
        Parameters:
        steganographicData - a byte array containing an mp3 file that has a message hidden within
        seed - seed that was used to encode the given stenographicData
        Returns:
        a byte array containing the hidden message
        Throws:
        UnknownStegFormatException - if the message could not be read from the given byte array.
        AudioNotFoundException - If the given bytes either don't contain an mp3 file or the mp3 file is not supported by this algorithm
        java.lang.NullPointerException - If the given byte array is null or has length 0
      • isSteganographicData

        public boolean isSteganographicData​(byte[] data)
                                     throws AudioNotFoundException
        Checks if the given byte array contains a message that was hidden using the default seed.
        Specified by:
        isSteganographicData in interface Steganography
        Parameters:
        data - data to test
        Returns:
        true, if a message was found
        Throws:
        AudioNotFoundException - If the given bytes either don't contain an mp3 file or the mp3 file is not supported by this algorithm
        java.lang.NullPointerException - If the given byte array is null or has length 0
      • isSteganographicData

        public boolean isSteganographicData​(byte[] data,
                                            long seed)
                                     throws AudioNotFoundException
        Checks if the given byte array contains a message that was hidden using the given seed.
        Specified by:
        isSteganographicData in interface Steganography
        Parameters:
        data - data to test
        seed - seed the hidden message was encoded with
        Returns:
        true, if a message was found
        Throws:
        AudioNotFoundException - If the given bytes either don't contain an mp3 file or the mp3 file is not supported by this algorithm
        java.lang.NullPointerException - If the given byte array is null or has length 0