Package steganography.audio.mp3
Class MP3Steganography
- java.lang.Object
-
- steganography.audio.mp3.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
-
-
Constructor Summary
Constructors Constructor Description MP3Steganography()
Creates an instance using the default overlay.
The default is MP3Overlays.SEQUENCE_OVERLAY.MP3Steganography(MP3Overlays overlay)
Creates an instance using theMP3Overlay
provided.
-
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.
-
-
-
Constructor Detail
-
MP3Steganography
public MP3Steganography(MP3Overlays overlay)
Creates an instance using theMP3Overlay
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 interfaceSteganography
- Parameters:
carrier
- a byte array containing an mp3 filepayload
- 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 algorithmAudioCapacityException
- If the payload does not fit into the carrierjava.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 interfaceSteganography
- Parameters:
carrier
- a byte array containing an mp3 filepayload
- a byte array containing the messageseed
- 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 algorithmAudioCapacityException
- If the payload does not fit into the carrierjava.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 interfaceSteganography
- 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 algorithmjava.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 interfaceSteganography
- Parameters:
steganographicData
- a byte array containing an mp3 file that has a message hidden withinseed
- 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 algorithmjava.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 interfaceSteganography
- 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 algorithmjava.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 interfaceSteganography
- Parameters:
data
- data to testseed
- 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 algorithmjava.lang.NullPointerException
- If the given byte array is null or has length 0
-
-