Commit 3a1c73be by Tobias

started working on a command line interface

1 parent e4daf2fa
Showing 18 changed files with 192 additions and 36 deletions
......@@ -71,7 +71,13 @@
<artifactId>org.swtchart</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
......
package org.stegosuite;
import org.stegosuite.ui.Gui;
import org.stegosuite.ui.cli.Cli;
import org.stegosuite.ui.gui.Gui;
public class Stegosuite {
public static void main(String[] args) {
new Gui();
if (args.length == 0) {
new Gui();
} else {
new Cli(args);
}
}
}
package org.stegosuite.ui.cli;
import com.beust.jcommander.Parameter;
public class Arguments {
@Parameter(names = "-e", description = "Embed data into image")
private boolean embed = false;
@Parameter(names = "-x", description = "Extract data from image")
private boolean extract = false;
@Parameter(names = "-f", description = "File for embedding/extracting")
private String file;
@Parameter(names = "-s", description = "Stegokey")
private String stegokey;
@Parameter(names = "-m", description = "Message to embed")
private String message;
boolean isEmbed() {
return embed;
}
boolean isExtract() {
return extract;
}
String getFile() {
return file;
}
String getStegokey() {
return stegokey;
}
String getMessage() {
return message;
}
}
package org.stegosuite.ui.cli;
import java.io.File;
import java.io.IOException;
import org.stegosuite.image.embedding.EmbeddingMethod;
import org.stegosuite.image.embedding.gif.GIFSortedColorTable;
import org.stegosuite.image.embedding.gif.filter.GIFPointFilterNone;
import org.stegosuite.image.format.GIFImage;
import org.stegosuite.model.exception.SteganoEmbedException;
import org.stegosuite.model.exception.SteganoExtractException;
import org.stegosuite.model.exception.SteganoImageException;
import org.stegosuite.model.payload.Payload;
import org.stegosuite.model.payload.block.MessageBlock;
import com.beust.jcommander.JCommander;
public class Cli {
private String[] args;
private Arguments arguments;
public Cli(String[] s) {
args = s;
parseCli();
}
private void parseCli() {
arguments = new Arguments();
new JCommander(arguments, args);
if (arguments.isEmbed()) {
embed();
} else if (arguments.isExtract()) {
extract();
}
}
private void embed() {
String stegokey = arguments.getStegokey();
String message = arguments.getMessage();
String filePath = arguments.getFile();
Payload payload = new Payload();
payload.getBlocks().add(new MessageBlock(message));
payload.setSteganoPassword(stegokey);
// payload.setEncryptionPassword(null);
if (filePath.toLowerCase().endsWith("gif")) {
GIFImage gifImage = new GIFImage();
File file = new File(filePath);
try {
gifImage.load(file);
EmbeddingMethod<GIFImage> embeddingMethod = new GIFSortedColorTable(gifImage, new GIFPointFilterNone());
embeddingMethod.embed(payload, null, null);
String outputPath = filePath;
outputPath = new StringBuilder(outputPath).insert(outputPath.length() - 4, "_embed").toString();
gifImage.save(new File(outputPath));
} catch (SteganoEmbedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SteganoImageException e) {
e.printStackTrace();
}
} else if (filePath.toLowerCase().endsWith("bmp")) {
}
}
private void extract() {
String stegokey = arguments.getStegokey();
String filePath = arguments.getFile();
Payload payload = new Payload();
payload.setSteganoPassword(stegokey);
// payload.setEncryptionPassword(null);
if (filePath.toLowerCase().endsWith("gif")) {
GIFImage gifImage = new GIFImage();
File file = new File(filePath);
try {
gifImage.load(file);
EmbeddingMethod<GIFImage> embeddingMethod = new GIFSortedColorTable(gifImage, new GIFPointFilterNone());
embeddingMethod.extract(payload, null, null);
MessageBlock messageBlock = new MessageBlock();
messageBlock = (MessageBlock) payload.getBlocks().get(0);
System.out.println(messageBlock.getMessage());
} catch (SteganoExtractException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SteganoImageException e) {
e.printStackTrace();
}
} else if (filePath.toLowerCase().endsWith("bmp")) {
}
}
}
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import java.io.File;
import java.io.IOException;
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import java.io.File;
import java.io.IOException;
......@@ -35,8 +35,8 @@ import org.stegosuite.model.payload.Payload;
import org.stegosuite.model.payload.block.Block;
import org.stegosuite.model.payload.block.FileBlock;
import org.stegosuite.model.payload.block.MessageBlock;
import org.stegosuite.ui.embedding.Embedding;
import org.stegosuite.ui.embedding.EmbeddingFactory;
import org.stegosuite.ui.gui.embedding.Embedding;
import org.stegosuite.ui.gui.embedding.EmbeddingFactory;
/**
* Contains the GUI of the TabItem "Embed", which is for embedding data into images.
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import java.util.Observable;
import java.util.Observer;
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import java.io.File;
import java.nio.file.Files;
......@@ -34,8 +34,8 @@ import org.stegosuite.model.payload.Payload;
import org.stegosuite.model.payload.block.Block;
import org.stegosuite.model.payload.block.FileBlock;
import org.stegosuite.model.payload.block.MessageBlock;
import org.stegosuite.ui.embedding.Embedding;
import org.stegosuite.ui.embedding.EmbeddingFactory;
import org.stegosuite.ui.gui.embedding.Embedding;
import org.stegosuite.ui.gui.embedding.EmbeddingFactory;
/**
* Contains the GUI of the TabItem "Extract", which is for extracting data from images.
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.ImageData;
......
package org.stegosuite.ui;
package org.stegosuite.ui.gui;
import java.io.File;
......@@ -15,7 +15,7 @@ import org.stegosuite.image.format.GIFImage;
import org.stegosuite.image.format.ImageFormat;
import org.stegosuite.model.exception.SteganoImageException;
import org.stegosuite.model.payload.Payload;
import org.stegosuite.ui.embedding.Embedding;
import org.stegosuite.ui.gui.embedding.Embedding;
public abstract class SteganoUi {
......
package org.stegosuite.ui.embedding;
package org.stegosuite.ui.gui.embedding;
import java.io.IOException;
......@@ -7,9 +7,9 @@ import org.stegosuite.image.format.ImageFormat;
import org.stegosuite.model.exception.SteganoEmbedException;
import org.stegosuite.model.exception.SteganoExtractException;
import org.stegosuite.model.payload.Payload;
import org.stegosuite.ui.EmbedUi;
import org.stegosuite.ui.ExtractUi;
import org.stegosuite.ui.ImageContainer;
import org.stegosuite.ui.gui.EmbedUi;
import org.stegosuite.ui.gui.ExtractUi;
import org.stegosuite.ui.gui.ImageContainer;
/**
* Abstraction layer between the GUI and the embed/extract functions.
......
package org.stegosuite.ui.embedding;
package org.stegosuite.ui.gui.embedding;
import org.stegosuite.image.format.BMPImage;
import org.stegosuite.image.format.GIFImage;
......
package org.stegosuite.ui.embedding;
package org.stegosuite.ui.gui.embedding;
import java.io.IOException;
......@@ -15,9 +15,9 @@ import org.stegosuite.image.format.ImageFormat;
import org.stegosuite.model.exception.SteganoEmbedException;
import org.stegosuite.model.exception.SteganoExtractException;
import org.stegosuite.model.payload.Payload;
import org.stegosuite.ui.EmbedUi;
import org.stegosuite.ui.ExtractUi;
import org.stegosuite.ui.ImageContainer;
import org.stegosuite.ui.gui.EmbedUi;
import org.stegosuite.ui.gui.ExtractUi;
import org.stegosuite.ui.gui.ImageContainer;
/**
* Abstraction layer between the GUI and the embed/extract functions.
......
package org.stegosuite.ui.embedding;
package org.stegosuite.ui.gui.embedding;
import java.io.IOException;
......@@ -12,9 +12,9 @@ import org.stegosuite.image.format.ImageFormat;
import org.stegosuite.model.exception.SteganoEmbedException;
import org.stegosuite.model.exception.SteganoExtractException;
import org.stegosuite.model.payload.Payload;
import org.stegosuite.ui.EmbedUi;
import org.stegosuite.ui.ExtractUi;
import org.stegosuite.ui.ImageContainer;
import org.stegosuite.ui.gui.EmbedUi;
import org.stegosuite.ui.gui.ExtractUi;
import org.stegosuite.ui.gui.ImageContainer;
/**
* Abstraction layer between the GUI and the embed/extract functions.
......
package org.stegosuite.ui.embedding;
package org.stegosuite.ui.gui.embedding;
import java.awt.Color;
import java.io.IOException;
......@@ -16,9 +16,9 @@ import org.stegosuite.image.format.ImageFormat;
import org.stegosuite.model.exception.SteganoEmbedException;
import org.stegosuite.model.exception.SteganoExtractException;
import org.stegosuite.model.payload.Payload;
import org.stegosuite.ui.EmbedUi;
import org.stegosuite.ui.ExtractUi;
import org.stegosuite.ui.ImageContainer;
import org.stegosuite.ui.gui.EmbedUi;
import org.stegosuite.ui.gui.ExtractUi;
import org.stegosuite.ui.gui.ImageContainer;
/**
* Abstraction layer between the GUI and the embed/extract functions.
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!