Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions ImageSteganographyLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 26



defaultConfig {
minSdkVersion 19
targetSdkVersion 26
Expand All @@ -13,30 +11,60 @@ android {

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"



}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

checkTypes {
javaCompileOptions.annotationProcessorOptions.
classNames.add("org.checkerframework.checker.nullness.NullnessChecker")
// You can pass options like so:
// javaCompileOptions.annotationProcessorOptions.arguments.put("warns", "")
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

configurations {
checkerFrameworkAnnotatedJDK {
description = 'a copy of JDK classes with Checker Framework type qualifers inserted'
}
}


configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:23.1.1'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
ext.checkerFrameworkVersion = '2.7.0'
implementation "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
annotationProcessor "org.checkerframework:checker:${checkerFrameworkVersion}"
checkerFrameworkAnnotatedJDK "org.checkerframework:jdk8:${checkerFrameworkVersion}"
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile).all { compile ->
if (compile.name.contains("checkTypes")) {
compile.options.compilerArgs += [
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.ayush.imagesteganographylibrary.Text.ImageSteganography;

import org.checkerframework.checker.nullness.qual.RequiresNonNull;

/**
* This the callback interface for TextDecoding AsyncTask.
*/
Expand All @@ -10,6 +12,7 @@ public interface TextDecodingCallback {

void onStartTextEncoding();

// @RequiresNonNull("#1")
void onCompleteTextEncoding(ImageSteganography result);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.ayush.imagesteganographylibrary.Text.ImageSteganography;

import org.checkerframework.checker.nullness.qual.RequiresNonNull;

/**
* This the callback interface for TextEncoding AsyncTask.
*/
Expand All @@ -10,6 +12,7 @@ public interface TextEncodingCallback {

void onStartTextEncoding();

// @RequiresNonNull("#1")
void onCompleteTextEncoding(ImageSteganography result);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.Log;

import com.ayush.imagesteganographylibrary.Utils.Utility;

import org.checkerframework.checker.nullness.qual.RequiresNonNull;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -32,8 +35,9 @@ class EncodeDecode {
* @parameter : progressHandler {A handler interface, for the progress bar}
*/

// @RequiresNonNull({"#1", "#4"})
private static byte[] encodeMessage(int[] integer_pixel_array, int image_columns, int image_rows,
MessageEncodingStatus messageEncodingStatus, ProgressHandler progressHandler) {
MessageEncodingStatus messageEncodingStatus, @Nullable ProgressHandler progressHandler) {

//denotes RGB channels
int channels = 3;
Expand Down Expand Up @@ -105,8 +109,9 @@ private static byte[] encodeMessage(int[] integer_pixel_array, int image_columns
* @parameter : encrypted_message {string}
* @parameter : progressHandler {Progress bar handler}
*/
// @RequiresNonNull({"#1"})
public static List<Bitmap> encodeMessage(List<Bitmap> splitted_images,
String encrypted_message, ProgressHandler progressHandler) {
String encrypted_message, @Nullable ProgressHandler progressHandler) {

//Making result method

Expand Down Expand Up @@ -191,6 +196,7 @@ public static List<Bitmap> encodeMessage(List<Bitmap> splitted_images,
* @parameter : image_rows {Image height}
* @parameter : messageDecodingStatus {object}
*/
// @RequiresNonNull({"#1", "#4"})
private static void decodeMessage(byte[] byte_pixel_array, int image_columns,
int image_rows, MessageDecodingStatus messageDecodingStatus) {

Expand Down Expand Up @@ -231,7 +237,6 @@ private static void decodeMessage(byte[] byte_pixel_array, int image_columns,

String stra = new String(temp, Charset.forName("ISO-8859-1"));


messageDecodingStatus.setMessage(stra.substring(0, stra.length() - 1));
//end fixing

Expand Down Expand Up @@ -279,6 +284,7 @@ private static void decodeMessage(byte[] byte_pixel_array, int image_columns,
* @parameter : encodedImages {list of encode chunk images}
*/

// @RequiresNonNull("#1")
public static String decodeMessage(List<Bitmap> encodedImages) {

//Creating object
Expand Down Expand Up @@ -309,7 +315,7 @@ public static String decodeMessage(List<Bitmap> encodedImages) {
* @return : The number of pixel {integer}
* @parameter : message {Message to encode}
*/
public static int numberOfPixelForMessage(String message) {
public static int numberOfPixelForMessage(@Nullable String message) {
int result = -1;
if (message != null) {
message += END_MESSAGE_COSTANT;
Expand All @@ -323,8 +329,10 @@ public static int numberOfPixelForMessage(String message) {
//Progress handler class
public interface ProgressHandler {

// @RequiresNonNull("#1")
void setTotal(int tot);

// @RequiresNonNull("#1")
void increment(int inc);

void finished();
Expand Down Expand Up @@ -352,6 +360,7 @@ String getMessage() {
return message;
}

// @RequiresNonNull("#1")
void setMessage(String message) {
this.message = message;
}
Expand All @@ -365,6 +374,7 @@ private static class MessageEncodingStatus {
private byte[] byteArrayMessage;
private String message;

// @RequiresNonNull({"#1", "#2"})
MessageEncodingStatus(byte[] byteArrayMessage, String message) {
this.messageEncoded = false;
this.currentMessageIndex = 0;
Expand All @@ -380,6 +390,7 @@ public String getMessage() {
return message;
}

// @RequiresNonNull("#1")
public void setMessage(String message) {
this.message = message;
}
Expand All @@ -396,6 +407,7 @@ int getCurrentMessageIndex() {
return currentMessageIndex;
}

// @RequiresNonNull("#1")
public void setCurrentMessageIndex(int currentMessageIndex) {
this.currentMessageIndex = currentMessageIndex;
}
Expand All @@ -404,6 +416,7 @@ byte[] getByteArrayMessage() {
return byteArrayMessage;
}

// @RequiresNonNull("#1")
public void setByteArrayMessage(byte[] byteArrayMessage) {
this.byteArrayMessage = byteArrayMessage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.ayush.imagesteganographylibrary.Utils.Crypto;
import com.ayush.imagesteganographylibrary.Utils.Utility;

import org.checkerframework.checker.nullness.qual.RequiresNonNull;

/**
* This main class of the text steganography
*/
Expand Down Expand Up @@ -36,6 +38,7 @@ public ImageSteganography() {
this.encrypted_zip = new byte[0];
}

// @RequiresNonNull({"#1", "#2", "#3"})
public ImageSteganography(String message, String secret_key, Bitmap image) {

this.message = message;
Expand All @@ -58,6 +61,7 @@ public ImageSteganography(String message, String secret_key, Bitmap image) {

}

// @RequiresNonNull({"#1", "#2"})
public ImageSteganography(String secret_key, Bitmap image) {
this.secret_key = convertKeyTo128bit(secret_key);
this.image = image;
Expand Down Expand Up @@ -110,6 +114,7 @@ public static String decryptMessage(String message, String secret_key) {
return decrypted_message;
}

// @RequiresNonNull("#1")
private static String convertKeyTo128bit(String secret_key) {

StringBuilder result = new StringBuilder(secret_key);
Expand All @@ -131,6 +136,7 @@ public Bitmap getEncoded_image() {
return encoded_image;
}

// @RequiresNonNull("#1")
public void setEncoded_image(Bitmap encoded_image) {
this.encoded_image = encoded_image;
}
Expand All @@ -139,6 +145,7 @@ public String getMessage() {
return message;
}

// @RequiresNonNull("#1")
public void setMessage(String message) {
this.message = message;
}
Expand All @@ -147,6 +154,7 @@ public String getSecret_key() {
return secret_key;
}

// @RequiresNonNull("#1")
public void setSecret_key(String secret_key) {
this.secret_key = secret_key;
}
Expand All @@ -155,6 +163,7 @@ public byte[] getEncrypted_zip() {
return encrypted_zip;
}

// @RequiresNonNull("#1")
public void setEncrypted_zip(byte[] encrypted_zip) {
this.encrypted_zip = encrypted_zip;
}
Expand All @@ -163,6 +172,7 @@ public String getEncrypted_message() {
return encrypted_message;
}

// @RequiresNonNull("#1")
public void setEncrypted_message(String encrypted_message) {
this.encrypted_message = encrypted_message;
}
Expand All @@ -171,6 +181,7 @@ public Bitmap getImage() {
return image;
}

// @RequiresNonNull("#1")
public void setImage(Bitmap image) {
this.image = image;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import com.ayush.imagesteganographylibrary.Text.AsyncTaskCallback.TextDecodingCallback;
import com.ayush.imagesteganographylibrary.Utils.Utility;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.RequiresNonNull;

import java.util.List;

/**
Expand All @@ -23,17 +26,21 @@ public class TextDecoding extends AsyncTask<ImageSteganography, Void, ImageStega
private final ImageSteganography result;
//Callback interface for AsyncTask
private final TextDecodingCallback textDecodingCallback;
private ProgressDialog progressDialog;
private @Nullable ProgressDialog progressDialog;

public TextDecoding(Activity activity, TextDecodingCallback textDecodingCallback) {
// @RequiresNonNull("#2")
public TextDecoding(@Nullable Activity activity, TextDecodingCallback textDecodingCallback) {
super();
this.progressDialog = new ProgressDialog(activity);
if (activity != null) {
this.progressDialog = new ProgressDialog(activity);
}
this.textDecodingCallback = textDecodingCallback;
//making result object
this.result = new ImageSteganography();
}

//setting progress dialog if wanted
// @RequiresNonNull("#1")
public void setProgressDialog(ProgressDialog progressDialog) {
this.progressDialog = progressDialog;
}
Expand Down
Loading