• Stars
    star
    154
  • Rank 242,095 (Top 5 %)
  • Language
    Java
  • License
    MIT License
  • Created over 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✔️ Hide a secret message in an image

Image Steganography

Steganography is the process of hiding a secret message within a larger one in such a way that someone cannot know the presence or contents of the hidden message. Although related, Steganography is not to be confused with Encryption, which is the process of making a message unintelligible—Steganography attempts to hide the existence of communication. The main advantage of steganography algorithm is because of its simple security mechanism. Because the steganographic message is integrated invisibly and covered inside other harmless sources, it is very difficult to detect the message without knowing the existence and the appropriate encoding scheme .

Proposed Algorithm

The algorithm is more dedicated towards the algorithm proposed by Rosziati Ibrahim and Teoh Suk Kuan in their Research Paper published on February 25, 2011.

Encoding Algorithm

  • Firstly, the secret message that is extracted is compressed as the contents in the compressed string will significantly hard to detect and read, furthermore it reduces the size of string.
  • Secondly, the compressed string is encrypted with the secret key.
  • Finally, encoding the encrypted message in the image. It uses LSB steganographic embedding to encode data into an image. Once the message is encoded the process stops.

LSB(Least Significant Bit) Embedding

The LSB is the lowest significant bit in the byte value of the image pixel. The LSB based image steganography embeds the secret in the least significant bits of pixel values of the cover image (CVR). The concept of LSB Embedding is simple. It exploits the fact that the level of precision in many image formats is far greater than that perceivable by average human vision. Therefore, an altered image with slight variations in its colors will be indistinguishable from the original by a human being, just by looking at it. In conventional LSB technique, which requires eight bytes of pixels to store 1byte of secret data but in proposed LSB technique, just four bytes of pixels are sufficient to hold one message byte. Rest of the bits in the pixels remains the same. Following shows the bit level interpretation of the algorithm :

Decoding Algorithm

  • Firstly, decode the message from the encrypted image using LSB decoding.

  • Secondly, decrypt the compressed message from the decoded message using the secret key.

  • Finally, decompress the message to get the original compressed message.

Consider the following encoding, it is totally undetectable by human eyes.

Usage

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Now add the following dependency in your app's build.gradle

dependencies {
      implementation 'com.github.aagarwal1012:Image-Steganography-Library-Android:v1.0'
}

How to encode message into an image ?

Note : Your Activity class should implements TextEncodingCallback interface and also contains its override methods.

public class MainActivity extends AppCompatActivity implements TextEncodingCallback 
  • Firstly, instantiate the ImageSteganography object and pass the values Message , Secret Key and Image Bitmap to the constructor.

    ImageSteganography imageSteganography = new ImageSteganography(message, 
                                            secret_key, 
                                            original_image);
  • Secondly, instantiate the TextEncoding object and pass the values Activity and TextEncodingCallback object to the constructor.

    TextEncoding textEncoding = new TextEncoding(MainActivity.this,
                                MainActivity.this);
  • Finally, execute our encoding task.

    textEncoding.execute(imageSteganography);

Note : By default a ProgressDialog will appear in the process of text encoding.

Override Methods

  • OnStartTextEncoding() : In this method you can whatever by the start of text encoding process.

    @Override
        public void onStartTextEncoding() {
            //Whatever you want to do at the start of text encoding
        }
  • onCompleteTextEncoding() : After the completion of text encoding, this method is called and gives result.

    @Override
        public void onCompleteTextEncoding(ImageSteganography result) {
    
            //After the completion of text encoding.
            
            //result object is instantiated 
            this.result = result;
    
            if (result != null && result.isEncoded()){
                
                //encrypted image bitmap is extracted from result object
                encoded_image = result.getEncrypted_image();
                
                //set text and image to the UI component.
                textView.setText("Encoded");
                imageView.setImageBitmap(encoded_image);
        }

How to decode message from an image ?

Note : Your Activity class should implements TextDecodingCallback interface and also contains its override methods.

public class MainActivity extends AppCompatActivity implements TextDecodingCallback 
  • Firstly, instantiate the ImageSteganography object and pass the values Secret Key and Image Bitmap to the constructor.

    ImageSteganography imageSteganography = new ImageSteganography(secret_key,
                                            original_image);
  • Secondly, instantiate the TextDecoding object and pass the values Activity and TextDecodingCallback object to the constructor.

    TextDecoding textDecoding = new TextDecoding(MainActivity.this, 
                                MainActivity.this);
  • Finally, execute our decoding task.

    textDecoding.execute(imageSteganography);

    Note : By default a ProgressDialog will appear in the process of text decoding.

Override Methods

  • OnStartTextDecoding() : In this method you can whatever by the start of text decoding process.

    @Override
        public void onStartTextDecoding() {
            //Whatever you want to do at the start of text encoding
        }
  • onCompleteTextDecoding() : After the completion of text decoding, this method is called and gives result.

    @Override
        public void onCompleteTextEncoding(ImageSteganography result) {
    
            //After the completion of text encoding.
            
            //result object is instantiated 
            this.result = result;
    
            if (result != null){
                
                /* If result.isDecoded() is false, it means no Message was found in 					the image. */
                if (!result.isDecoded())
                    textView.setText("No message found");
                
                else{
                    /* If result.isSecretKeyWrong() is true, it means that secret key provided 				is wrong. */ 
                    if (!result.isSecretKeyWrong()){
                        //set the message to the UI component.
                        textView.setText("Decoded");
                        message.setText("" + result.getMessage());
                    }
                    else {
                        textView.setText("Wrong secret key");
                    }
                }
            }
            else {
                //If result is null it means that bitmap is null
                textView.setText("Select Image First");
            }
        }

Documentation

ImageSteganography Class

Java attribute Java set methods Description Default Value
Message setMessage(...) , getMessage() Set the value of message, Get the value of message. Null
Secret_Key setSecret_key(...) Set the value of secret key. Null
Image setImage(...) Set the value of image. Null
Encoded_Image getEncoded_image() Get the value of encoded image after text encoding. Null
Encoded isEncoded() Check that the encoding is over or not false
Decoded isDecoded() Check that the decoding is over or not. false
SecretKeyWrong isSecretKeyWrong() Check that the secret key provided was right or wrong but after decoding was done. true

Class Domain Diagram

Example App

There are two options Encode and Decode. In the encode section you can hide a secret message into an image without making any noticeable changes. In the decode section you can extract the message from the encoded image by inserting the correct key.

Note - After pressing the Save button, both the original and encoded images are saved at the location Android/data/com.ayush.steganography/files/Documents/<UUID>/

Encode Decode

Want to contribute !

This is the well documented library. I have documented each and every method that I have used, so have a good read to the code and suggest some changes and new feature to be added in the library.
Feel free to open an issue.

Donate

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Ryan Hayes
Ryan Hayes

🚧 🤔 🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Image Steganography is licensed under MIT license.

MIT License

Copyright (c) 2018 Ayush Agarwal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

Animated-Text-Kit

🔔 A flutter package to create cool and beautiful text animations. [Flutter Favorite Package]
Dart
1,664
star
2

Liquid-Pull-To-Refresh

🔁 A custom refresh indicator for flutter.
Dart
1,249
star
3

IntroViews-Flutter

☀️ A Flutter package for some material design app intro screens with some cool animations.
Dart
664
star
4

Daily-Prophet-AR

📰 Augmented Reality implementation of Daily Prophet newspaper from Harry Potter
C#
23
star
5

Github-Actions-Flutter

Test, build, analyze, check code formatting and build APK for the Flutter project using Github Actions.
Dart
19
star
6

Home-Automation

📱 Home Automation System using an Arduino board with Bluetooth being remotely controlled by any Android OS smartphone.
Java
13
star
7

Debug-Thugs

A mobile based product which records the road quality in runtime and processes on algorithms indigenously. App made for HackInOut 2018.
Jupyter Notebook
7
star
8

CSN-361-Assignments

🔥 Assignments of course CSN-361, Computer networks laboratory
HTML
3
star
9

Tensorflow-In-Android

Using tensorflow in android
Java
3
star
10

aagarwal1012.github.io

🌏 My old website
CSS
2
star
11

Claim-It

🌟 Insurance.Claim.Simplified
JavaScript
2
star
12

android-resource-checker

✅ Resource checker for the checker framework.
Java
2
star
13

blog

My old blog, inspired from Jekyll Type-on-Strap theme.
HTML
1
star
14

Maharo-Doctor-Android

Android application for Rajasthan Hackathon 2k18
Java
1
star
15

aagarwal1012

🤗My Github profile Readme.
1
star
16

hello-github-actions

Learning about GitHub actions!
Dockerfile
1
star
17

uKnow

CFD 2k18
Java
1
star
18

AnonyTweet

An android app where anonymity is the priority.
Java
1
star
19

ProgTrack

CSN-501 Mini Project for Group 18
JavaScript
1
star