You are on page 1of 160

ICLES'

MOTILAL JHUNJHUNWALA COLLEGE

OF ARTS, SCIENCE & COMMERCE


Sector 9 A, Vashi, Navi Mumbai – 400 703

PROJECT REPORT

ON

Steganography

Submitted to

Mumbai University, Mumbai

UNIVERSITY OF MUMBAI

In the partial fulfillment of the degree of


Bachelor of Computer Science (B.Sc.CS)
By
Atul Mahendra Vasave
Under the Guidance of
Ms.Ashwini ingulkar mam
(2018-2019)

ICLES'
MOTILAL JHUNJHUNWALA COLLEGE

OF ARTS , SCIENCE & COMMERCE,VASHI


Certificate

This is to certify that the project entitled

Steganography

Undertaken by
Atul Mahendra Vasave

during the academic year 2018-2019.In partial fulfillment of


B.Sc.CS(Computer Science) Examination.
It is further certified that he has completed all required phases of the
project as given by University of Mumbai.

Project Guide Principal

External Examiner IT/CS Coordinator


ACKNOWLEDGEMENT

I would especially thank all teaching and non-teaching staff of


COMPUTER SCIENCE faculty for inspiring me in completion of project. I am
thankful to my project guide Ms. Ashwini Ingulkar for her timely help and
guidance in completing this project successfully.

I would also extend my thanks to our IT/CS Coordinator Mrs.Trupti


Kulkarni for her support and facilities provides to us for the same.

Lastly I would like to thank all those who directly and indirectly helped in
completion of this project.

Date: Completed by,

Place: Vashi Atul Mahendra Vasave


Index
Sr. Page
Topic
No. No.
1. 1 Preliminary Investigation
1.1 b) Description of System
1.2 c) Limitations of present system
1.3 d) Proposed system & its advantages
1.4 e) Feasibility Study

1.5 g) Gantt Chart

2. 2 System Analysis

2.1 b) Use Case Diagram

2.2 c) ERD

2.3 d) Activity Diagram

2.4 e) Class Diagram

2.5 f) Object Diagram

2.6 g) State Diagram

2.7 h) Sequence Diagram

3. 3 System Design

3.1 b) Component Diagram

3.2 c) Package Diagrams

3.3 d) Deployment Diagram

3.4 e) Test Cases

4. 4 System Coding

4.1 a) List of tables with attributes and constraints

b) Program Description
4.2

5. 5 System Implementation

6. 6 Future Enhancements

7. 7 Bibliography
Preliminary Investigation
ABSTRACT

Steganography is the art of hiding the fact that communication is taking place, by
hiding information in other information. Many different carrier file formats can be
used, but digital images are the most popular because of their frequency on the
internet. For hiding secret information in images, there exists a large variety of
steganography techniques some are more complex than others and all of them have
respective strong and weak points. Different applications may require absolute
invisibility of the secret information, while others require a large secret message to
be hidden. This project report intends to give an overview of image steganography,
its uses and techniques. It also attempts to identify the requirements of a good
steganography algorithm and briefly reflects on which steganographic techniques
are more suitable for which applications.

Overview of Stegnography
This application lets you embed or hide important or private messages or files
into picture files like JPG, GIF and BMP Bitmap images without affecting the
quality of actual images or files. It achieves this by using the least significant
bits of these files for embedding data which are not used by the Image viewers
or Image editors.

It allows you to embed the messages or files in Encrypted form using 32 bit
DES algorithm which means that once encrypted, the message or file could be
retrieved (or decrypted) from a Master file only after specifying the correct
Password which was used at the time of encryption.
INTRODUCTION

One of the reasons that intruders can be successful is the most of the information
they acquire from a system is in a form that they can read and comprehend.
Intruders may reveal the information to others, modify it to misrepresent an
individual or organization, or use it to launch an attack. One solution to this problem
is, through the use of steganography. Steganography is a technique of hiding
information in digital media. In contrast to cryptography, it is not to keep others
from knowing the hidden information but it is to keep others from thinking that the
information even exists.

Steganography become more important as more people join the cyberspace


revolution. Steganography is the art of concealing information in ways that prevents
the detection of hidden messages. Stegranography include an array of secret
communication methods that hide the message from being seen or discovered.

Due to advances in ICT, most of information is kept electronically. Consequently, the


security of information has become a fundamental issue. Besides cryptography,
streganography can be employed to secure information. In cryptography, the
message or encrypted message is embedded in a digital host before passing it
through the network, thus the existence of the message is unknown. Besides hiding
data for confidentiality, this approach of information hiding can be extended to
copyright protection for digital media: audio, video and images.

The growing possibilities of modern communications need the special means of


security especially on computer network. The network security is becoming more
important as the number of data being exchanged on the internet increases.
Therefore, the confidentiality and data integrity are requires to protect against
unauthorized access and use. This has resulted in an explosive growth of the field of
information hiding
Information hiding is an emerging research area, which encompasses applications
such as copyright protection for digital media, watermarking, fingerprinting, and
steganography.

In watermarking applications, the message contains information such as owner


identification and a digital time stamp, which usually applied for copyright
protection.Fingerprint, the owner of the data set embeds a serial number that
uniquely identifies the user of the data set. This adds to copyright information to
makes it possible to trace any unauthorized used of the data set back to the user.

Steganography hide the secrete message within the host data set and presence
imperceptible and is to be reliably communicated to a receiver. The host data set is
purposely corrupted, but in a covert way, designed to be invisible to an information
analysis.

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 tohide the existence of communication.

The basic structure of Steganography is made up of three components:

The“carrier”, the message, and the key1. The carrier can be a painting, a
digital image, anmp3, even a TCP/IP packet among other things. It is the object
that will ‘carry’ thehidden message. A key is used to decode/decipher/discover
the hidden message.This can be anything from a password, a pattern, a black-
light, or even lemon juice.In this paper I will focus on the use of Steganography
within digital images (BMPand PNG) using LSB Substitution, although the
properties of Image Steganographymay be substituted with audio mp3’s, zip
archives, and any other digital documentformat relatively easily.
What is Steganography?

Steganography is the practice of hiding private or sensitive information within


something that appears to be nothing out to the usual. Steganography is often
confused with cryptology because the two are similar in the way that they both are
used to protect important information. The difference between two is that
steganography involves hiding information so it appears that no information is
hidden at all. If a person or persons views the object that the information is hidden
inside of he or she will have no idea that there is any hidden information, therefore
the person will not attempt to decrypt the information.

What steganography essentially does is exploit human perception, human senses are
not trained to look for files that have information inside of them, although this
software is available that can do what is called Steganography. The most common
use of steganography is to hide a file inside another file.
History of Steganography:

Through out history Steganography has been used to secretly communicate


information between people.

Some examples of use of Steganography is past times are:

1. During World War 2 invisible ink was used to write information on pieces of
paper so that the paper appeared to the average person as just being blank
pieces of paper. Liquids such as milk, vinegar and fruit juices were used,
because when each one of these substances are heated they darken and
become visible to the human eye.
2. In Ancient Greece they used to select messengers and shave their head, they
would then write a message on their head. Once the message had been
written the hair was allowed to grow back. After the hair grew back the
messenger was sent to deliver the message, the recipient would shave off the
messengers hair to see the secrete message.
3. Another method used in Greece was where someone would peel wax off a
tablet that was

Why This Steganography?

This technique is chosen, because this system includes not only imperceptibility but
also un-delectability by any steganolysis tool.
LIMITATIONS

 Anyone can see the Important message and secret data.


 The general Problem of Existing System is Speed.
 Record handling again issues in manual system.
 Error & mistakes are there in system.
 If we not create encrypted the file and Messages then hacker hack the
important file.
 For storing data it requires large space.
 To get more time to get a file and important Messages

FEATURES

 Hide archives inside any images type.

 Open the hidden files from within the program itself.

 View a preview before creating.

 Embedding a message in an uncompressed format file.

 Embedding a file into an uncompressed format file.

 Retrieving message from a Master file.

 Retrieving embedded file from a Master file:


ADVANTAGE

 Steganography allows for two parties to communicate secretly and covertly.


 Every Transaction is obtained & processed immediately.
 The data embedding is achieved in a content-based manner by modifying the
wavelet transform coefficients of those robust regions.
 User friendly screen to enter the data & enquiry about the database table.
 Portable & flexible for future extension.
 Provide the Hardware & software securities.
 Enhance automation in Stenography operational providing speed & cost
benefits.
 To integrate with specified password for the readers.
 Experimental results show the proposed algorithm allows hiding data
invisibly with an accurate retrieval in the presence of loss compression or
noise.
 it allows for copyright protection on digital files using the message as a
digital
watermark.
 This project is integrated in multiple branches simultaneously so that
processing must faster.
Feasibility
 Feasibility Study :

Feasibility study is conducted once the problem is clearly


understood feasibility study is a high level capsule version of the entire at
minimum expense show to solve a problem .

The purpose of feasibility study I not to solve a problem, but to


determine if the problem is worth solving.

The following points analyze how feasible is the system for the
organization. In other words, these points elaborate on the benefits of the
proposed system.

 The system has been tested for Feasibility study the following point
1. Technical analysis.

2. Economical analysis

3. Operational analysis.

4. Motivational analysis.

5. Legal analysis.
 Technical Feasibility :
The project entities “Stenography” is technical feasibility because of the
below mentioned features . The project was develop in which
GUI(Graphical user interface).It provides the high level of reliability,
availability & compatibility. All these make an appropriate language for this
project thus the existing s/w java is a powerful language. The system has
been proposed on a java platform. This is an upcoming technology and have
favored in the market for a long time now. The backend used is Microsoft
Office Access 2003,, which is also one of the favored database management
systems.

 Economical Feasibility :
The computerized system will help in automate the selection leading
the profit and details of the organization with the s/w .The machine and
manpower utilization are expected to go up by 80-90% appropriate of not
creating the system are set to be great because time can be wanted by
manually.

 The system will save time.


 At t he same time the system will require less manual power as compared
to the current system. There is no training cost.
 The storage and handling problem with respect to registers will be solved.
 Operational Feasibility :
In this project the management will know the details of each
project where he may be presented and the data will be maintained as
decentralized and if any inquires for that particular contract can be know
as per their requirement and necessaries. The proposed system is
operationally feasible as it would increase the throughput and reduce the
response time to some extent.

 Motivational Feasibility :

The users who want to install this software will obviously know the
advantages of using computerized system. Since the new system will be
simple and user friendly, the office won’t have any problem in switching
over to computerized system. That is why this system is motivationally
feasible.

 Legal Feasibility :
The company has licensed copy of JDK 1.6 & Microsoft Office Access
2003, which have been used for the development of the system with java as the
front end and Microsoft Office 2003 as the back end.So from the legal point of
view, this software is feasible.
 GANTT CHART:

No. Task Start End 2016 -17


Sep Oct Dec Feb
1 Analysis
15/09/16 5/10/16
15/09/16 5/10/16

2 Planning
6/10/16 30/10/16
6/10/16 30/10/16

3 Designing
1/11/16 5/12/16
1/11/16 5/12/16

4 Coding
6/12/16 31/1/17
6/12/16 31/1/17

5 Testing
1/2/17 16/2/17
1/2/17 16/2/17

Estimated Time:
Actual Time:
System Analysis
EXISTING SYSTEM

 The Current System is working manually so the Management of Records is


quite uncomfortable.
 The purpose of Steganography is to maintain secret communication between
two parties.
 So the work load is very high.

DRAWBAKES OF EXISTING SYSTEM


 Existing system is manual.
 Creation of Reports is very hectic. If any error occurs while creating a report
then the whole report has to be regenerated
which is time consuming.
 There is no systematic recording of the reports & information.
 The system is time consuming and tedious
PROPOSED SYSTEM

 Steganography and Cryptography are two popular ways of sending vital


information in a secret way.
 One hides the existence of the message and the other distorts the message
itself.
 There are many cryptography techniques available; among them AES is one
of the most powerful techniques. In Steganography we have various
techniques in different domains like spatial domain, frequency domain etc. to
hide the message.
 In this project we are developing a system where we develop a new
technique in which Cryptography and Steganography are used as integrated
part along with newly developed enhanced security module.
 In Cryptography we are using DES algorithm to encrypt a message and a
part of the message is hidden in DCT of an image.
ADVANTAGE OF PROPOSED SYSTEM

 Avoiding communication in well-known forms greatly reduces the risk of


information being leaked in transit.
 Another form of Steganography, called watermarking is used primarily for
identification and entails embedding a unique piece of information within a
medium without noticeably altering the medium.
 Steganography can also enhance individual privacy.
 This is effective only if the hidden communication is not detected.
 The most private communication is the one that never existed.
USE CASE DIAGRAM

User name

Password

ADMIN
Select the Master file

Select the Output file

Choose the options to be used while


embedding message.

EMBED Specify Compression and encryption to use


MESSAGE
Select the Master file

Specify Compression and


encryption to use

To get a Message

RETRIEVE
MESSAGE
Select the Master file

Select the Output file

Select the Data file

EMBED FILE
Specify Compression and encryption to
use

booking
report
Select the Master file

Select the Data file

Specify Compression and encryption to


use

To get actual file which is encrypted


RETRIVE
FILE
booking
report
CLASS DIAGRAM

Login System
User_Name
Retrieve File
Embed File Password
Security Hint Master File
...* 1
Master File Forgot password Output File
Output File …* 1 Encrypted
1 File
Data File To get File
…*
Compress File
Encrypted File
* …

*…

1 1

1 Retrieve Message
Master File
Embed Message …*
Output File
Master File 1 Encrypted File
Output File To get Message
Compress File
Encrypted File
POD_No
1

…*
Help
About Stenography
Help
1
OBJECT DIAGRAM

Login System
User_Name
Retrieve File
Embed File Password
Security Hint Master File
...* 1
Master File Forgot password Output File
Output File …* 1 Encrypted
1 File
Data File To get File
…*
Compress File
Encrypted File
* …

*…

1 1

1 Retrieve Message
Master File
Embed Message …*
Output File
Master File 1 Encrypted File
Output File To get Message
Compress File
Encrypted File
POD_No
1

…*
Help
About Stenography
Help
1
CONTEX LEVEL DFD

START APLICATION

Embed File Retrieve


File

Output File
Master Output Data
File File File

Secrete Key

Compre Encrypt Secrete Embedded File


ss File ed File Key
ACTIVITY DIAGRAM

login file Message

Login the
applicatio
n

Embed file

Retrieve file

Embed Message

Retrieve Message
Embed Message Retrieve Message

Choose
Master file

Choose output file

Compress the file

Encrypted the file


Embed file Retrieve file

Choose
Master file

Choose output file

Choose data file

Compress &
Encrypted file
SEQUENCE DIAGRAM

Embed Retrieve
File File

User

Master file

Output file Choose Master file

Data File

Encrypted file Use Encrypted


File

To get a file
Embed Retrieve
Message Message

User

Master file

Output file Choose Master file

Type Message

Encrypted file Use Encrypted


File

To get a Message
SYSTEM FLOW CHART
STRUCTURE CHART

Stenography

Login Embed Retrieve Embed Retrieve


file file Message Message

Master Master
Master file Add branch
file file
and modify
Output
file

Choose selected Master file

Compress & Encrypted the message

Compress the Encrypted the


file& Message file & Message
System Analysis & Design

Steganography system requires any type of image file and the information or
message that is to be hidden. It has two modules encrypt and decrypt.

Microsoft .Net framework prepares a huge amount of tool and options for
programmers that they simples programming. One of .Net tools for pictures and
images is auto-converting most types of pictures to BMP format. I used this tool in
this software called “Steganography” that is written in C#.Net language and you can
use this software to hide your information in any type of pictures without any
converting its format to BMP (software converts inside it).

The algorithm used for Encryption and Decryption in this application provides
using several layers lieu of using only LSB layer of image. Writing data starts from
last layer (8st or LSB layer); because significant of this layer is least and every upper
layer has doubled significant from its down layer. So every step we go to upper layer
image quality decreases and image retouching transpires.

The encrypt module is used to hide information into the image; no one can see that
information or file. This module requires any type of image and message and gives
the only one image file in destination.

The decrypt module is used to get the hidden information in an image file. It take the
image file as an output, and give two file at destination folder, one is the same image
file and another is the message file that is hidden it that.

Before encrypting file inside image we must save name and size of file in a definite
place of image. We could save file name before file information in LSB layer and
save file size and file name size in most right-down pixels of image. Writing this
information is needed to retrieve file from encrypted image in decryption state.

The graphical representation of this system is as follows:


Start Application

Encryption Decryption

Image Message file Image file

BMP image file


Encryption Process

IMAGE FILE INFORMATION FILE

BMP FILE
Decryption Process

BMP FILE

INFORMATION FILE IMAGE FILE


System Design
PACKEGE DIAGRAM

Stenography

Embed File Retrieve File

Select Master File Choose Master File

Encrypted File
Select Output File

Use Secrete Key


Select Data File

To get a File
Compress file

Encrypted File
DEPLOYMENT DIAGRAM

HDD

<MEMORY>

CPU
PRINTER
<PROCESS> MONITOR

SQL

SERVER
Bitmap Steganography:

Bitmap type is the simplest type of picture because that it doesn’t have any
technology for decreasing file size. Structure of these files is that a bitmap image
created from pixels that any pixel created from three colors ( red, green and blue said
RGB) each color of a pixel is one byte information that shows the density of that
color. Merging these three color makes every color that we see in these pictures. We
know that every byte in computer science is created from 8 bit that first bit is Most-
Significant-Bit (MSB) and last bit Least-Significant-Bit (LSB), the idea of using
Steganography science is in this place; we use LSB bit for writing our security
information inside BMP pictures. So if we just use last layer (8st layar) of
information, we should change the last bit of pixels, in other hands we have 3 bits in
each pixel so we have 3*hight*width bits memory to write our information. But
before writing our data we must write name of data(file), size of name of data & size
of data. We can do this by assigning some first bits of memory (8st layer).

(00101101 00011101 11011100)

(10100110 11000101 00001100)

(11010010 10101100 01100011)

Using each 3 pixel of picture to save a byte of data


System Coding
import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.ImageIcon;

import javax.swing.JOptionPane;

import javax.swing.JPasswordField;

import javax.swing.JButton;

import javax.swing.JRootPane;

import javax.swing.JTextField;

import javax.swing.SwingConstants;

import java.awt.*;

import java.awt.event.MouseListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

public class LoginUI extends JFrame implements ActionListener

int value=0;

Font SecChkFont=new Font("Arial",0,30);

FontMetrics fm;

JTextField EntLogin;
JPasswordField EntPass;

JLabel Hnt;

String getInfo[];

public void paint(Graphics g)

fm=g.getFontMetrics(SecChkFont);

public LoginUI(String title)

super(title);

setSize(400,300);

repaint();

Dimension dim = getToolkit().getScreenSize();

Container c=getContentPane();

c.setLayout(null);

setResizable(false);

setIconImage(new ImageIcon("FSPIcon.jpg").getImage());

ImageIcon SCIcon=new ImageIcon("Lock.jpg");

JLabel Sc=new JLabel(SCIcon);

JLabel SecChk=new JLabel("Security Check");

JLabel Login=new JLabel("Login",SwingConstants.RIGHT);

JLabel Pass=new JLabel("Password",SwingConstants.RIGHT);


ImageIcon HntIcon=new ImageIcon("Hint.jpg");

Hnt=new JLabel(HntIcon);

EntLogin=new JTextField(20);

EntPass=new JPasswordField(20);

JButton LogIn=new JButton("Login");

setLocation((dim.width)/2 - getWidth()/2,(dim.height)/2-getHeight()/2);

//setUndecorated(true);

//getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

SecChk.setFont(SecChkFont);

FontMetrics fm=SecChk.getFontMetrics(SecChkFont);

SecChk.setBounds(getWidth()/2-
fm.stringWidth(SecChk.getText())/2,30,210,50);

Sc.setBounds(12,15,80,84);

Login.setBounds(60,80,80,50);

Pass.setBounds(60,110,80,50);

EntLogin.setBounds(150,95,160,25);

EntPass.setBounds(150,125,160,25);

Hnt.setBounds(320,115,32,38);
LogIn.setBounds(getWidth()/2-70,190,150,25);

Hnt.setToolTipText("Hint: Either You Have it or You Don't");

c.add(Sc);

c.add(SecChk);

c.add(Login);

c.add(Pass);

c.add(EntLogin);

c.add(EntPass);

c.add(Hnt);

c.add(LogIn);

addWindowListener(new WindowAdapter()

public void windowClosing(WindowEvent we)

setVisible(false);

System.exit(1);

});

LogIn.addActionListener(this);

try
{

DataConnection.getConnection();

getInfo=DataConnection.getLogIn();

System.out.print("\nCome In");

if(DataConnection.isDatabaseBlank())

MainClient mc=new MainClient();

//mc.setVisible(true);

//setVisible(true); //after the main form is Created

setVisible(false);

DataConnection.close();

catch(Exception e)

JOptionPane.showMessageDialog(this,"One Of File is
Missing","Error",JOptionPane.ERROR_MESSAGE);

System.exit(1);

Hnt.setToolTipText(getInfo[2]);

public void actionPerformed(ActionEvent ae)

{
if(ae.getActionCommand().equals("Login"))

if(EntLogin.getText().length()==0 || EntPass.getText().length()==0)

JOptionPane.showMessageDialog(this,"Enter the Login and Password


then\nClick On LogIn","LogIn",JOptionPane.ERROR_MESSAGE);

EntLogin.setText("");

EntPass.setText("");

else

if(!(EntLogin.getText().equals(getInfo[0]) &&
EntPass.getText().equals(getInfo[1])))

JOptionPane.showMessageDialog(this,"LogIn or Password are


Incorrect","InValid",JOptionPane.ERROR_MESSAGE,new
ImageIcon("Error.jpg"));

EntLogin.setText("");

EntPass.setText("");

else

MainClient mc=new MainClient();

//setVisible(true);

//setVisible(false);

}
}

/*public static void main(String arg[])

try{

DataConnection.getConnection();

boolean isDatabaseBlank=DataConnection.isDatabaseBlank();

DataConnection.close();

if(isDatabaseBlank){

DataConnection.close();

MainFormUI mf=new MainFormUI("File Shredder and Protector");

mf.setVisible(true);

else{

LoginUI obj=new LoginUI("File Shredder and Protector - LogIn Form");

DataConnection.close();

obj.setVisible(true);

catch(Exception e){

JOptionPane.showMessageDialog(new JButton(),"One of the file of s/w is


missing","Error",JOptionPane.ERROR_MESSAGE,new
ImageIcon("Error.jpg"));
System.exit(1);

}*/

 Main Client

import javax.swing.*;

import javax.swing.border.TitledBorder;

import java.awt.*;

import java.awt.event.*;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.ImageIcon;

import javax.swing.JOptionPane;

import javax.swing.JDesktopPane;

import java.awt.event.MouseListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

public class MainClient extends WindowAdapter implements ActionListener

{
private JFrame mainFrame;

private JMenuBar menuBar;

private JMenu menuFile, menuEdit, menuHelp;

private JMenuItem mnuExit, mnuEmbedMessage, mnuEmbedFile, mnuHelp,


mnuAbout;

private JMenuItem mnuRetrieveMessage, mnuRetrieveFile, mnuModifyMaster;

private JPanel mainPanel, panelAbout, panelButtons;

private JLabel lblLogo;

private JLabel lblFiller[];

private GridBagLayout gbl;

private GridBagConstraints gbc;

private MyJButton btnEmbedFile, btnRetrieveFile, btnEmbedMessage,


btnRetrieveMessage;

private MyJButton btnHelp, btnAbout;

private BackEndHandler back;

public MainClient()

mainFrame= new JFrame("Steganograph");

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mainFrame.addWindowListener(this);

// Setup the menu bar

mnuExit= new MyJMenuItem("Exit", 1, 'x');

mnuEmbedMessage= new MyJMenuItem("Embed Message", 6, 'm');


mnuEmbedFile= new MyJMenuItem("Embed File", 7, 'i');

mnuRetrieveMessage= new MyJMenuItem("Retrieve Message", 0, 'r');

mnuRetrieveFile= new MyJMenuItem("Retrieve File", 2, 't');

mnuModifyMaster= new MyJMenuItem("Modify Master file settings", 2, 'd');

mnuHelp= new MyJMenuItem("Help", 0, 'h');

mnuAbout= new MyJMenuItem("About Steganograph",0,'a');

// Add action listeners for other menu items

mnuEmbedMessage.addActionListener(this);

mnuEmbedFile.addActionListener(this);

mnuRetrieveMessage.addActionListener(this);

mnuRetrieveFile.addActionListener(this);

mnuModifyMaster.addActionListener(this);

mnuExit.addActionListener(this);

mnuHelp.addActionListener(this);

mnuAbout.addActionListener(this);

menuFile= new MyJMenu("File", 0, 'f');

menuFile.add(mnuEmbedMessage);

menuFile.add(mnuEmbedFile);

menuFile.add(mnuRetrieveMessage);

menuFile.add(mnuRetrieveFile);

menuFile.add(mnuExit);

menuEdit= new JMenu("Edit");

menuEdit.add(mnuModifyMaster);
menuHelp= new MyJMenu("Help", 0, 'h');

menuHelp.add(mnuHelp);

menuHelp.add(mnuAbout);

menuBar= new JMenuBar();

menuBar.add(menuFile);

//menuBar.add(menuEdit);

menuBar.add(menuHelp);

mainFrame.setJMenuBar(menuBar);

mainPanel= new JPanel();

panelAbout= new JPanel();

panelButtons= new JPanel();

// Create filler labels

lblFiller= new JLabel[4];

for(int i=0; i<4; i++)

lblFiller[i]= new JLabel(" ");

// Prepare About panel

gbl= new GridBagLayout();

gbc= new GridBagConstraints();

panelAbout.setLayout(gbl);

panelAbout.setBackground(Color.white);

Color myColor= new Color(50, 153, 237);

Font arialFont= new Font("Arial", Font.PLAIN, 14);


Font myFont= new Font("Monotype Corsiva", Font.PLAIN, 18);

// Prepare the Buttons panel

panelButtons.setBackground(Color.white);

gbl= new GridBagLayout();

panelButtons.setLayout(gbl);

panelButtons.setBorder(new TitledBorder("Supported operations"));

lblLogo= new JLabel(new ImageIcon("Images/Logo"));

btnEmbedMessage= new MyJButton("Images/EmbedMessage",


"Images/EmbedMessageHover");

btnEmbedFile= new MyJButton("Images/EmbedFile",


"Images/EmbedFileHover");

btnRetrieveMessage= new MyJButton("Images/RetrieveMessage",


"Images/RetrieveMessageHover");

btnRetrieveFile= new MyJButton("Images/RetrieveFile",


"Images/RetrieveFileHover");

btnHelp= new MyJButton("Images/Help", "Images/HelpHover");

btnAbout= new MyJButton("Images/About", "Images/AboutHover");

// Add action listeners for the buttons

btnEmbedMessage.addActionListener(this);

btnEmbedFile.addActionListener(this);

btnRetrieveMessage.addActionListener(this);

btnRetrieveFile.addActionListener(this);

btnHelp.addActionListener(this);

btnAbout.addActionListener(this);
// Add filler for rows 1 and 2

gbc.weightx= 4; gbc.weighty= 2; gbc.fill= gbc.BOTH;

gbc.gridx= 6; gbc.gridy= 1; gbl.setConstraints(lblFiller[0], gbc);

panelButtons.add(lblFiller[0]);

gbc.weightx= 1; gbc.weighty= 1; gbc.fill= gbc.NONE;

gbc.gridx= 3; gbc.gridy= 3; gbl.setConstraints(btnHelp, gbc);

panelButtons.add(btnHelp);

gbc.gridx= 5; gbl.setConstraints(btnAbout, gbc);

panelButtons.add(btnAbout);

// Add filler for rows 4 and 5

gbc.fill = gbc.BOTH;

gbc.gridx= 1; gbc.weighty= 2; gbc.gridy= 4;


gbl.setConstraints(lblFiller[1], gbc);

panelButtons.add(lblFiller[1]);

gbc.fill= gbc.NONE;

gbc.gridx= 2; gbc.weighty= 1; gbc.gridy= 6;


gbl.setConstraints(btnEmbedMessage, gbc);

panelButtons.add(btnEmbedMessage);

gbc.gridx= 4; gbl.setConstraints(btnRetrieveMessage, gbc);

panelButtons.add(btnRetrieveMessage);

// Add filler for row 7 and 8


gbc.fill = gbc.BOTH;

gbc.gridx= 6; gbc.weighty= 2; gbc.gridy= 7;


gbl.setConstraints(lblFiller[2], gbc);

panelButtons.add(lblFiller[2]);

gbc.fill= gbc.NONE;

gbc.gridx= 3; gbc.weighty= 1; gbc.gridy= 9;


gbl.setConstraints(btnEmbedFile, gbc);

panelButtons.add(btnEmbedFile);

gbc.gridx= 5; gbl.setConstraints(btnRetrieveFile, gbc);

panelButtons.add(btnRetrieveFile);

// Add the lblLogo and two Panels to the mainPanel

gbl= new GridBagLayout();

mainPanel.setLayout(gbl);

mainPanel.setBackground(Color.white);

gbc.anchor= gbc.CENTER;

gbc.gridx= 1; gbc.gridy= 1; gbc.weighty= 2; gbc.fill=


gbc.VERTICAL;

gbl.setConstraints(lblLogo, gbc);

mainPanel.add(lblLogo);

gbc.gridy= 3; gbc.weighty= 2;

gbl.setConstraints(panelAbout, gbc);

mainPanel.add(panelAbout);
gbc.gridy= 5; gbc.weighty= 1;

gbl.setConstraints(panelButtons, gbc);

mainPanel.add(panelButtons);

gbc.gridy= 6; gbc.weighty= 2;

gbl.setConstraints(lblFiller[3], gbc);

mainPanel.add(lblFiller[3]);

JPanel tempPanel= (JPanel) mainFrame.getContentPane();

tempPanel.add(mainPanel, BorderLayout.CENTER);

tempPanel.add(new MyJLabel(" ", Color.black, Color.darkGray),


BorderLayout.SOUTH);

Dimension d= Toolkit.getDefaultToolkit().getScreenSize();

mainFrame.setSize(d.width, (int) (d.height-(d.height*.03)));

mainFrame.setResizable(false);

mainFrame.setVisible(true);

// Listener methods

public void actionPerformed(ActionEvent e)

Object source= e.getSource();

// Embed message operation

if(source== mnuEmbedMessage || source== btnEmbedMessage)

{
back= new BackEndHandler(this, BackEndHandler.EMBED_MESSAGE);

back.start();

// Retrieve message operation

if(source== mnuRetrieveMessage || source== btnRetrieveMessage)

back= new BackEndHandler(this, BackEndHandler.RETRIEVE_MESSAGE);

back.start();

// Embed file operation

if(source== mnuEmbedFile || source== btnEmbedFile )

back= new BackEndHandler(this, BackEndHandler.EMBED_FILE);

back.start();

// Retrieve file operation

if(source== mnuRetrieveFile || source== btnRetrieveFile )

back= new BackEndHandler(this, BackEndHandler.RETRIEVE_FILE);

back.start();

// Modify Master file operation


if(source== mnuModifyMaster)

back= new BackEndHandler(this, BackEndHandler.EDIT_MASTER);

back.start();

if(source== mnuHelp || source==btnHelp)

Steganograph.showHelpDialog();

if(source== mnuAbout || source== btnAbout)

Steganograph.showAboutDialog();

if(source== mnuExit)

int result= JOptionPane.showConfirmDialog(mainFrame, "Are you sure that


you want to close Steganograph.", "Confirm Exit",
JOptionPane.YES_NO_OPTION);

if(result== JOptionPane.YES_OPTION)

JOptionPane.showMessageDialog(mainFrame, "Thanks for using this


Steganograph.", "", JOptionPane.INFORMATION_MESSAGE);

System.exit(0);

public void windowClosing(WindowEvent w)

{
JOptionPane.showMessageDialog(mainFrame, "Thanks for using this
Steganograph.", "Confirm Exit", JOptionPane.INFORMATION_MESSAGE);

// Main method

public static void main(String args[])

MainClient mc=new MainClient();

//mc.setVisible(true);

//LoginUI lg=new LoginUI();

//lg.setVisible(false);

) )

Start Screen:
import javax.swing.*;
import java.awt.*;

public class StartScreen extends JFrame


{
StartScreen()
{
setSize(664,246);

JDesktopPane desk=new JDesktopPane();


Dimension dim = getToolkit().getScreenSize();
setLocation((dim.width)/2 - getWidth()/2,(dim.height)/2-getHeight()/2);

setUndecorated(true);
setResizable(false);
ImageIcon icon = new ImageIcon("green.jpg");
//ImageIcon icon = new
ImageIcon("E:/Steganograph/image/green.gpg");
JLabel l = new JLabel(icon);
l.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
// Place the image in the lowest possible layer so nothing
// can ever be painted under it.
desk.add(l, new Integer(Integer.MIN_VALUE));
JProgressBar progBar=new
JProgressBar(JProgressBar.HORIZONTAL,0,100);
desk.setLayout(null);
desk.add(progBar);
getContentPane().add(desk);

progBar.setBounds(50,190,580,30); //123,244,50
progBar.setStringPainted(true);
progBar.setBackground(Color.white);
progBar.setForeground(new Color(123,244,50));
progBar.setBorderPainted(true);
progBar.setValue(0);
//progBar.setOpaque(false);
int value=0;
setVisible(true);
while(progBar.getValue()!=100)
{
try{
progBar.setValue(value);
value++;
Thread.sleep(25);
}
catch(Exception e){
}

}
}
 Start :
import javax.swing.*;

import java.lang.String.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.ImageIcon;

import javax.swing.JOptionPane;

import javax.swing.JPasswordField;

import javax.swing.JButton;

import javax.swing.JRootPane;

import javax.swing.JTextField;

import javax.swing.SwingConstants;

import java.awt.*;

import java.awt.event.MouseListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

class Start{

public static void main(String arg[])


{

try{

try{

StartScreen startScreen=new StartScreen();

startScreen.setVisible(false);

catch(Exception ee){ }

DataConnection.getConnection();

boolean
isDatabaseBlank=DataConnection.isDatabaseBlank();

DataConnection.close();

if(isDatabaseBlank)

DataConnection.close();

MainClient mc=new MainClient();

//mc.setVisible(true);

else{

LoginUI obj=new LoginUI("Stegnography -


LogIn Form");

obj.setVisible(true);

DataConnection.close();

}
}

catch(Exception e){

//JOptionPane.showMessageDialog(new JButton(),"One of
the file of s/w is missing","Error",JOptionPane.ERROR_MESSAGE,new
ImageIcon("Error.jpg"));

//System.exit(1);

 Stegnograph :
import java.io.*;
import java.nio.ByteBuffer;
import java.util.zip.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
/*** 2 bytes representing the size of the actual file
* 3 bytes indicate the version of the software used to embed message eg. 2
00
* 1 Byte1 (4 actual bits) incicates features used which include file
Compression, Encryption, Message/File
* 1 byte contains the compression ratio
* 4 bytes Contain the size of the data (A 32 bit integer value)
***/
public class Steganograph
{
public static final String VERSION= "2.0.0";
public static final byte[] VERSION_BYTE= {'2','0','0'};
public static final int OFFSET_JPG= 3;
public static final int OFFSET_PNG= 42;
public static final int OFFSET_GIF_BMP_TIF= 32;
public static final short HEADER_LENGTH= 15* 4;
// Three letters indicate:
// Uncompressed/Compressed Encrypted/Unencrypted Message/File
public static final byte UUM= 0;
public static final byte UUF= 1;
public static final byte UEM= 2;
public static final byte UEF= 3;
public static final byte CUM= 4;
public static final byte CUF= 5;
public static final byte CEM= 6;
public static final byte CEF= 7;

private static Cipher cipher;


private static SecretKeySpec spec;
private static String masterExtension, message;
private static AboutFrame about= new AboutFrame();

private static File masterFile;


// This byte stores the features being used by the file
private static byte features;
private static int inputFileSize;
private static int i, j, inputOutputMarker, messageSize, tempInt;
private static short compressionRatio= 0, temp;
private static byte byte1, byte2, byte3, byteArrayIn[];
private static ByteArrayOutputStream byteOut;
private Steganograph()
{
System.out.println("Steganograph ready...");
}

public static String getMessage()


{
return message;
}
// Embeds a message into a Master file
public static boolean embedMessage(File masterFile, File outputFile,
String msg, int compression, String password)
{
if(msg==null)
{
message= "Message is empty";
return false;
}
if(msg.length()<1)
{
message= "Message is empty";
return false;
}

if(password!= null && password.length()<8)


{
message= "Password should be minimum of 8 Characters";
return false;
}

messageSize= msg.length();

if(compression!= -1)
{
// Make sure that the compression is a valid numerical
between 0 and 9
if(compression< 0) compression= 0;
if(compression>9) compression= 9;

if(password== null) features= CUM;


else features= CEM;
}
else
{
if(password== null) features= UUM;
else features= UEM;
}

try
{
byteOut= new ByteArrayOutputStream();
// Convert message into a character array
byte []messageArray= msg.getBytes();
messageSize= messageArray.length;
inputFileSize= (int) masterFile.length();
// create a byte array of length equal to size of input file
byteArrayIn= new byte[inputFileSize];
// Open the input file read all bytes into byteArrayIn
DataInputStream in= new DataInputStream(new
FileInputStream(masterFile));
in.read(byteArrayIn, 0, inputFileSize);
in.close();
String fileName= masterFile.getName();
masterExtension= fileName.substring(fileName.length()-3,
fileName.length());
if(masterExtension.equalsIgnoreCase("jpg"))
{
// Skip past OFFSET_JPG bytes
byteOut.write(byteArrayIn, 0, OFFSET_JPG);
inputOutputMarker= OFFSET_JPG;
}
else if(masterExtension.equalsIgnoreCase("png"))
{
// Skip past OFFSET_PNG bytes
byteOut.write(byteArrayIn, 0,
OFFSET_PNG);
inputOutputMarker= OFFSET_PNG;
}
else
{
// Skip past OFFSET_JPG_BMP_TIF
bytes
byteOut.write(byteArrayIn, 0,
OFFSET_GIF_BMP_TIF);
inputOutputMarker=
OFFSET_GIF_BMP_TIF;
}
// Convert the 32 bit input file size into byte array
byte tempByte[]= new byte[4];
for(i=24, j=0; i>=0; i-=8, j++)
{
tempInt= inputFileSize;
tempInt>>= i;
tempInt&= 0x000000FF;
tempByte[j]= (byte) tempInt;
}
// Embed 4 byte input File size array into the master file
embedBytes(tempByte);

// Write the remaining bytes


byteOut.write(byteArrayIn, inputOutputMarker,
inputFileSize- inputOutputMarker);
inputOutputMarker= inputFileSize;
// Embed the 3 byte version information into the file
writeBytes(VERSION_BYTE);

// Write 1 byte for features


writeBytes(new byte[]{features});

// Compress the message if required


if(features== CUM || features== CEM)
{
ByteArrayOutputStream arrayOutputStream= new
ByteArrayOutputStream();
ZipOutputStream zOut= new
ZipOutputStream(arrayOutputStream);
ZipEntry entry= new ZipEntry("MESSAGE");
zOut.setLevel(compression);
zOut.putNextEntry(entry);

zOut.write(messageArray, 0, messageSize);
zOut.closeEntry();
zOut.finish();
zOut.close();
// Get the compressed message byte array
messageArray= arrayOutputStream.toByteArray();
compressionRatio= (short)
((double)messageArray.length / (double)messageSize * 100.0);
messageSize= messageArray.length;
}
// Embed 1 byte compression ratio into the output file
writeBytes(new byte[]{(byte) compressionRatio});
// Encrypt the message if required
if(features== UEM || features== CEM)
{
Cipher cipher= Cipher.getInstance("DES");
SecretKeySpec spec= new
SecretKeySpec(password.substring(0, 8).getBytes(), "DES");
cipher.init(Cipher.ENCRYPT_MODE, spec);
messageArray= cipher.doFinal(messageArray);
messageSize= messageArray.length;
}
// Convery the 32 bit message size into byte array
tempByte= new byte[4];
for(i=24, j=0; i>=0; i-=8, j++)
{
tempInt= messageSize;
tempInt>>= i;
tempInt&= 0x000000FF;
tempByte[j]= (byte) tempInt;
}
// Embed 4 byte messageSize array into the master file
writeBytes(tempByte);

// Embed the message


writeBytes(messageArray);

DataOutputStream out= new DataOutputStream(new


FileOutputStream(outputFile));
//out.write(byteArrayOut, 0, byteArrayOut.length);
byteOut.writeTo(out);
out.close();
}
catch(EOFException e)
{
}
catch(Exception e)
{
message= "Oops!!\nError: "+ e.toString();
e.printStackTrace();
return false;
}
message= "Message embedded successfully in file '"+
outputFile.getName()+ "'.";
return true;
}
// Retrieves an embedded message from a Master file
public static String retrieveMessage(SteganoInformation info, String
password)
{
String messg= null;
features= info.getFeatures();

try
{
masterFile= info.getFile();
byteArrayIn= new byte[(int) masterFile.length()];
DataInputStream in= new DataInputStream(new
FileInputStream(masterFile));
in.read(byteArrayIn, 0, (int)masterFile.length());
in.close();

messageSize= info.getDataLength();

if(messageSize<=0)
{
message= "Unexpected size of message: 0.";
return("#FAILED#");
}

byte[] messageArray= new byte[messageSize];


inputOutputMarker= info.getInputMarker();
readBytes(messageArray);
//Decrypt the message if required
if(features== CEM || features== UEM)
{
password= password.substring(0, 8);
byte passwordBytes[]= password.getBytes();

cipher= Cipher.getInstance("DES");
spec= new SecretKeySpec(passwordBytes, "DES");
cipher.init(Cipher.DECRYPT_MODE, spec);
try
{
messageArray= cipher.doFinal(messageArray);
}
catch(Exception bp)
{
message= "Incorrent Password";
bp.printStackTrace();
return "#FAILED#";
}
messageSize= messageArray.length;
}

// Uncompress the message if required


if(features== CUM || features== CEM)
{
ByteArrayOutputStream by= new
ByteArrayOutputStream();
DataOutputStream out= new DataOutputStream(by);

ZipInputStream zipIn= new ZipInputStream(new


ByteArrayInputStream(messageArray));
zipIn.getNextEntry();
byteArrayIn= new byte[1024];
while((tempInt= zipIn.read(byteArrayIn, 0, 1024))!= -
1)
out.write(byteArrayIn, 0, tempInt);
zipIn.close();
out.close();
messageArray= by.toByteArray();
messageSize= messageArray.length;
}
messg= new
String(SteganoInformation.byteToCharArray(messageArray));
}
catch(Exception e)
{
message= "Oops!!\n Error: "+ e;
e.printStackTrace();
return("#FAILED#");
}

message= "Message size: "+ messageSize+ " B";


return messg;
}

// Embeds a file into a Master file


public static boolean embedFile(File masterFile, File outputFile, File
dataFile, int compression, String password)
{
messageSize= (int) dataFile.length();

if(password!= null && password.length()<8)


{
message= "Password should be minimum of 8 Characters";
return false;
}
if(compression!= 0)
{
// Make sure that the compression is a valid numerical
between 0 and 9
if(compression< 0) compression= 0;
if(compression>9) compression= 9;

if(password== null) features= CUF;


else features= CEF;
}
else
{
if(password== null) features= UUF;
else features= UEF;
}

inputFileSize= (int) masterFile.length();


try
{
byteOut= new ByteArrayOutputStream();

// create a byte array of length equal to size of input file


byteArrayIn= new byte[inputFileSize];
// Open the input file read all bytes into byteArrayIn
DataInputStream in= new DataInputStream(new
FileInputStream(masterFile));
in.read(byteArrayIn, 0, inputFileSize);
in.close();
String fileName= masterFile.getName();
masterExtension= fileName.substring(fileName.length()-3,
fileName.length());

if(masterExtension.equalsIgnoreCase("jpg"))
{
// Skip past OFFSET_JPG bytes
byteOut.write(byteArrayIn, 0, OFFSET_JPG);
inputOutputMarker= OFFSET_JPG;
}
else if(masterExtension.equalsIgnoreCase("png"))
{
// Skip past OFFSET_PNG bytes
byteOut.write(byteArrayIn, 0,
OFFSET_PNG);
inputOutputMarker= OFFSET_PNG;
}
else
{
// Skip past OFFSET_GIF_BMP_TIF
bytes
byteOut.write(byteArrayIn, 0,
OFFSET_GIF_BMP_TIF);
inputOutputMarker=
OFFSET_GIF_BMP_TIF;
}
// Convert the 32 bit input file size into byte array
byte tempByte[]= new byte[4];
for(i=24, j=0; i>=0; i-=8, j++)
{
tempInt= inputFileSize;
tempInt>>= i;
tempInt&= 0x000000FF;
tempByte[j]= (byte) tempInt;
}
// Embed 4 byte input File size array into the master file
embedBytes(tempByte);
// Write the remaining bytes
byteOut.write(byteArrayIn, inputOutputMarker,
inputFileSize- inputOutputMarker);
inputOutputMarker= inputFileSize;
// Embed the 3 byte version information into the file
writeBytes(VERSION_BYTE);
// Write 1 byte for features
writeBytes(new byte[]{features});

// Read the data bytes into fileArray


byte []fileArray= new byte[messageSize];
in= new DataInputStream(new FileInputStream(dataFile));
in.read(fileArray, 0, messageSize);
in.close();
// Compress the message if required
if(features== CUF || features== CEF)
{
ByteArrayOutputStream arrayOutputStream= new
ByteArrayOutputStream();
ZipOutputStream zOut= new
ZipOutputStream(arrayOutputStream);
ZipEntry entry= new ZipEntry(dataFile.getName());
zOut.setLevel(compression);
zOut.putNextEntry(entry);
zOut.write(fileArray, 0, messageSize);
zOut.closeEntry();
zOut.finish();
zOut.close();
// Get the compressed message byte array
fileArray= arrayOutputStream.toByteArray();
compressionRatio= (short) ((double)fileArray.length /
(double)messageSize * 100.0);
messageSize= fileArray.length;
}
// Embed 1 byte compression ratio into the output file
writeBytes(new byte[]{(byte) compressionRatio});
// Encrypt the message if required
if(features== UEF || features== CEF)
{
Cipher cipher= Cipher.getInstance("DES");
SecretKeySpec spec= new
SecretKeySpec(password.substring(0, 8).getBytes(), "DES");
cipher.init(Cipher.ENCRYPT_MODE, spec);
fileArray= cipher.doFinal(fileArray);
messageSize= fileArray.length;
}

// Convery the 32 bit message size into byte array


tempByte= new byte[4];
for(i=24, j=0; i>=0; i-=8, j++)
{
tempInt= messageSize;
tempInt>>= i;
tempInt&= 0x000000FF;
tempByte[j]= (byte) tempInt;
}
// Embed 4 byte messageSize array into the master file
writeBytes(tempByte);

// Embed the message


writeBytes(fileArray);
DataOutputStream out= new DataOutputStream(new
FileOutputStream(outputFile));
byteOut.writeTo(out);
out.close();
}
catch(EOFException e)
{
}
catch(Exception e)
{
message= "Oops!!\nError: "+ e.toString();
e.printStackTrace();
return false;
}
message= "File '"+ dataFile.getName()+ "' embedded successfully
in file '"+ outputFile.getName()+ "'.";
return true;
}
// Retrieves an embedded file from a Master file
public static boolean retrieveFile(SteganoInformation info, String
password, boolean overwrite)
{
File dataFile= null;
features= info.getFeatures();
try
{
masterFile= info.getFile();
byteArrayIn= new byte[(int) masterFile.length()];

DataInputStream in= new DataInputStream(new


FileInputStream(masterFile));
in.read(byteArrayIn, 0, (int)masterFile.length());
in.close();
messageSize= info.getDataLength();
byte[] fileArray= new byte[messageSize];
inputOutputMarker= info.getInputMarker();
readBytes(fileArray);
if(messageSize<=0)
{
message= "Unexpected size of embedded file: 0.";
return false;
}
//Decrypt the file if required
if(features== CEF || features== UEF)
{
password= password.substring(0, 8);
byte passwordBytes[]= password.getBytes();
cipher= Cipher.getInstance("DES");
spec= new SecretKeySpec(passwordBytes, "DES");
cipher.init(Cipher.DECRYPT_MODE, spec);
try
{
fileArray= cipher.doFinal(fileArray);
}
catch(Exception bp)
{
message= "Incorrent Password";
bp.printStackTrace();
return false;
}
messageSize= fileArray.length;
}

// Uncompress the file if required


if(features== CUF || features== CEF)
{
ByteArrayOutputStream by= new
ByteArrayOutputStream();
DataOutputStream out= new DataOutputStream(by);
ZipInputStream zipIn= new ZipInputStream(new
ByteArrayInputStream(fileArray));
ZipEntry entry= zipIn.getNextEntry();
dataFile= new File(entry.getName());

byteArrayIn= new byte[1024];


while((tempInt= zipIn.read(byteArrayIn, 0, 1024))!= -
1)
out.write(byteArrayIn, 0, tempInt);
zipIn.close();
out.close();
fileArray= by.toByteArray();
messageSize= fileArray.length;
}

info.setDataFile(dataFile);
if(dataFile.exists() && !overwrite)
{
message= "File Exists";
return false;
}

DataOutputStream out= new DataOutputStream(new


FileOutputStream(dataFile));
out.write(fileArray, 0, fileArray.length);
out.close();
}
catch(Exception e)
{
message= "Oops!!\n Error: "+ e;
e.printStackTrace();
return false;
}
message= "Retrieved file size: "+ messageSize+ " B";
return true;
}
// Method used to write bytes into the output array
private static void embedBytes(byte[] bytes)
{
int size= bytes.length;
for(int i=0; i< size; i++)
{
byte1= bytes[i];
for(int j=6; j>=0; j-=2)
{
byte2= byte1;
byte2>>= j;
byte2&= 0x03;
byte3= byteArrayIn[inputOutputMarker];
byte3&= 0xFC;
byte3|= byte2;
byteOut.write(byte3);
inputOutputMarker++;
}
}
}
// Method used to write bytes into the output array
private static void writeBytes(byte[] bytes)
{
int size= bytes.length;

for(int i=0; i< size; i++)


{
byteOut.write(bytes[i]);
inputOutputMarker++;
}
}
// Method used to retrieve bytes into the output array
private static void retrieveBytes(byte[] bytes)
{
int size= bytes.length;
for(int i=0; i< size; i++)
{
byte1= 0;
for(int j=6; j>=0; j-=2)
{
byte2= byteArrayIn[inputOutputMarker];
inputOutputMarker++;
byte2&= 0x03;
byte2<<= j;
byte1|= byte2;
}
bytes[i]= byte1;
}
}
// Method used to read bytes into the output array
private static void readBytes(byte[] bytes)
{
int size= bytes.length;
for(int i=0; i< size; i++)
{
bytes[i]= byteArrayIn[inputOutputMarker];
inputOutputMarker++;
}
}
public static void showAboutDialog()
{
about.setDisplayed(true);
}
public static void updateUserInterface()
{
SwingUtilities.updateComponentTreeUI(about);
}

public static void showHelpDialog()


{
new HTMLFrame("file:"+ System.getProperty("user.dir") +
System.getProperty("file.separator") +
"help.html", false);
}
//**********************************************************
***********//
// Inner class for description about Steganograph in a frame
private static class AboutFrame extends JFrame implements
ActionListener
{
private final Color GREEN= Color.green;
private final Color YELLOW= Color.yellow;
private final Color BLACK= Color.black;
private JLabel lblTitle, lblImage, lblName, lblEmail;
private JLabel filler1, filler2, filler3;
private JButton btnHelp, btnClose;
private GridBagLayout gbl;
private GridBagConstraints gbc;
public AboutFrame()
{
setTitle("About Steganograph ");
filler1= new JLabel(" "); filler2= new JLabel(" "); filler3=
new JLabel(" ");
lblTitle= new MyJLabel("Steganography Implementation ",
new Font("Arial", Font.PLAIN, 15), YELLOW, BLACK);
lblName= new MyJLabel("By: Rakesh", new
Font("Monotype Corsiva", Font.PLAIN, 14), GREEN, BLACK);
lblEmail= new MyJLabel("
rakesh999ovhal@gmail.com", GREEN, BLACK);
if(new File("Images/About").exists())
lblImage= new JLabel(new
ImageIcon("Images/Myself"));
else
{
lblImage= new MyJLabel("Steganograph ", new
Font("Times new roman", Font.PLAIN, 50), Color.red, Color.black);
lblImage.setPreferredSize(new Dimension(222, 231));
}
btnHelp= new MyJButton("Help", GREEN, BLACK);
btnClose= new MyJButton("Close", GREEN, BLACK);

btnHelp.addActionListener(this);
btnClose.addActionListener(this);
JPanel panelAbout= new JPanel();
panelAbout.setBackground(BLACK);
panelAbout.setForeground(GREEN);
gbl= new GridBagLayout();
gbc= new GridBagConstraints();
panelAbout.setLayout(gbl);;

gbc.anchor= GridBagConstraints.CENTER;
gbc.weightx= 2;
gbc.weighty= 2;
gbc.gridx= 1; gbc.gridy= 1;
gbl.setConstraints(lblTitle, gbc);
panelAbout.add(lblTitle);
gbc.gridy= 2; gbl.setConstraints(filler1, gbc);
panelAbout.add(filler1);
gbc.gridy= 3; gbl.setConstraints(lblName, gbc);
panelAbout.add(lblName);
gbc.gridy= 4; gbl.setConstraints(filler2, gbc);
panelAbout.add(filler2);
gbc.gridy= 5; gbl.setConstraints(lblEmail, gbc);
panelAbout.add(lblEmail);
gbc.gridy= 6; gbl.setConstraints(filler3, gbc);
panelAbout.add(filler3);
panelAbout=
UtilityOperations.createBorderedPanel(panelAbout, "About Steganograph",
3, 3);
JPanel panelUpper= new JPanel();
panelUpper.setBackground(BLACK);
panelUpper.setLayout(new FlowLayout());
panelUpper.add(lblImage);
panelUpper.add(new MyJLabel(" ", GREEN, BLACK));
panelUpper.add(panelAbout);
JPanel panelButtons= new JPanel();
panelButtons.setBackground(Color.black);
panelButtons.setLayout(new FlowLayout());
panelButtons.setBackground(Color.black);
panelButtons.add(new JLabel(" "));
panelButtons.add(btnHelp);
panelButtons.add(new JLabel(" "));
panelButtons.add(btnClose);
JPanel mainPanel= new JPanel();
mainPanel.setBackground(Color.black);
gbl= new GridBagLayout();
mainPanel.setLayout(gbl);
gbc.gridx= 1; gbc.gridy= 1;
gbl.setConstraints(panelUpper, gbc);
mainPanel.add(panelUpper);
gbc.gridy= 2; gbl.setConstraints(panelButtons, gbc);
mainPanel.add(panelButtons);
mainPanel=
UtilityOperations.createBorderedPanel(mainPanel, 3, 2);
setContentPane(mainPanel);
Dimension d= Toolkit.getDefaultToolkit().getScreenSize();
int width= (int) (d.width*2.1/3);
int height= (int) (d.height*1.9)/3;
setSize(width, height);
setLocation((d.width- width)/2, (d.height- height)/2);
setResizable(false);
}
public void setDisplayed(boolean choice)
{
setVisible(choice);
}

public void actionPerformed(ActionEvent e)


{
if(e.getSource()== btnHelp)
new HTMLFrame("file:"+
System.getProperty("user.dir") +
System.getProperty("file.separator") +
"help.html", false);
if(e.getSource()== btnClose)
setVisible(false);
}
} // End of Class AboutFrame
} // End of Class Steganograph
// Class to obtain information about a Steganograph file
class SteganoInformation
{
private File file;
private File dataFile= null;
private String starter;
private String version;
private byte features;
private short compressionRatio;
private int dataLength, temp;
private boolean isEster= false;
private byte byteArray[], name[], byte1, byte2;
private int inputMarker, i, j;
// Accessor methods
public File getFile() { return file; }
public int getInputMarker() { return inputMarker; }
public File getDataFile() { return dataFile; }
public String getVersion() { return version; }
public byte getFeatures() { return features; }
public short getCompressionRatio() { return compressionRatio; }
public int getDataLength() { return dataLength; }
public boolean isEster() { return isEster; }
// Mutator methods
public void setDataFile(File dataFile)
{
this.dataFile= dataFile;
}
private void retrieveBytes(byte[] bytes, byte[] array, int marker)
{
byteArray= array;
inputMarker= marker;
int size= bytes.length;

for(i=0; i< size; i++)


{
byte1= 0;
for(j=6; j>=0; j-=2)
{
byte2= byteArray[inputMarker];
inputMarker++;

byte2&= 0x03;
byte2<<= j;
byte1|= byte2;
}
bytes[i]= byte1;
}
}
private void retrieveBytes(byte[] bytes)
{
int size= bytes.length;

for(i=0; i< size; i++)


{
byte1= 0;
for(j=6; j>=0; j-=2)
{
byte2= byteArray[inputMarker];
inputMarker++;

byte2&= 0x03;
byte2<<= j;
byte1|= byte2;
}
bytes[i]= byte1;
}
}
private void readBytes(byte[] bytes, byte[] array, int marker)
{
byteArray= array;
inputMarker= marker;

int size= bytes.length;

for(i=0; i< size; i++)


{
bytes[i]= byteArray[inputMarker];
inputMarker++;
}
}
private void readBytes(byte[] bytes)
{
int size= bytes.length;

for(i=0; i< size; i++)


{
bytes[i]= byteArray[inputMarker];
inputMarker++;
}
}

public static char[] byteToCharArray(byte[] bytes)


{
int size= bytes.length, i;
char []chars= new char[size];
for(i=0; i<size; i++)
{
bytes[i]&= 0x7F;
chars[i]= (char) bytes[i];
}
return chars;
}
public SteganoInformation(File file)
{
this.file= file;
isEster= false;

if(!file.exists())
{
starter= null;
return;
}
if(file.getName().equals("Sec#x&y"))
{
isEster= true;
return;
}
byteArray= new byte[(int) file.length()];
try
{
DataInputStream in= new DataInputStream(new
FileInputStream(file));
in.read(byteArray, 0, (int) file.length());
in.close();
}
catch(Exception e)
{
starter= null;
return;
}

// Obtain the original file length


name= new byte[4];

String fileName= file.getName();


String fileExtension= fileName.substring(fileName.length()-3,
fileName.length());

if(fileExtension.equalsIgnoreCase("jpg"))
inputMarker= Steganograph.OFFSET_JPG;
else if(fileExtension.equalsIgnoreCase("png"))
inputMarker= Steganograph.OFFSET_PNG;
else
inputMarker=
Steganograph.OFFSET_GIF_BMP_TIF;

retrieveBytes(name, byteArray, inputMarker);


dataLength= 0;
for(i=24,j=0; i>=0; i-=8,j++)
{
temp= name[j];
temp&= 0x000000FF;
temp<<= i;
dataLength|= temp;
}
inputMarker= dataLength;

if(dataLength<0 || dataLength>file.length())
{
starter= "Invalid";
return;
}
else
starter= "Rakesh";

// Retrive the name and version information


byte versionArray[]= new byte[3];
readBytes(versionArray, byteArray, inputMarker);
char []versionTemp= byteToCharArray(versionArray);
char []ver= new char[5];
for(i=0, j=0; i<5; i++)
if(i== 1 || i== 3) ver[i]= '.';
else
{
ver[i]= versionTemp[j++];
}

version= new String(ver);


// Obtain the features
name= new byte[1];
readBytes(name);
features= name[0];

// Obtain the compression ratio


readBytes(name);
name[0]&= 0x7F;
compressionRatio= name[0];

// Obtain the data length


name= new byte[4];
readBytes(name);
dataLength= 0;
for(i=24,j=0; i>=0; i-=8,j++)
{
temp= name[j];
temp&= 0x000000FF;
temp<<= i;
dataLength|= temp;
}
}

public boolean isValid()


{
if(starter.equals("Rakesh"))
{
return true;
}
else
return false;
}
}

class HTMLFrame extends JFrame implements HyperlinkListener


{
JEditorPane editorPane;
JScrollPane scrollPane;

public HTMLFrame(String startURL, boolean isOnline)


{
super("Help - Steganograph");

editorPane= new JEditorPane();


editorPane.setEditable(false);
if(isOnline)
{
editorPane.setBackground(Color.white);
setTitle("Steganograph");
}
//else
// editorPane.setBackground(Color.black);
editorPane.addHyperlinkListener(this);
scrollPane= new JScrollPane(editorPane);

try
{
editorPane.setPage(startURL);
getContentPane().add(scrollPane);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this, "Oops!! Error\n"+ e,
"Error", JOptionPane.WARNING_MESSAGE);
return;
}

Dimension d= Toolkit.getDefaultToolkit().getScreenSize();
setSize(d.width, d.height);
setVisible(true);
}

public void hyperlinkUpdate(HyperlinkEvent e)


{
if(e.getEventType()== HyperlinkEvent.EventType.ACTIVATED)
{
try
{
editorPane.setPage(e.getURL());
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(this, "Oops!!
Error\n"+ ex, "Error", JOptionPane.WARNING_MESSAGE);
}
}
}
}

Data Connection
import java.sql.*;
public class DataConnection
{
static Connection c;
static Statement s;
static public void getConnection() throws Exception
{
c=null;
try
{
String url="jdbc:odbc:Connection";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c = DriverManager.getConnection(url);
//System.out.print("Connection Successfully");
s=c.createStatement();
}
catch(Exception e)
{
System.out.print(e);
}
}
static String[] display(String tableName) throws Exception
{
s=c.createStatement();
ResultSet rs=s.executeQuery("Select * from "+tableName+"");
int i=0;
while(rs.next())
i++;
String display[]=new String[i];
rs=s.executeQuery("Select * from "+tableName+"");
i=0;
while(rs.next())
display[i++]=rs.getString(1);
return display;
}

static void addLogInName(String name,String password,String hint)


throws Exception
{
s.execute("INSERT INTO LogIn VALUES
('"+name+"','"+password+"','"+hint+"')");
}
static void removeLogIn() throws Exception
{
s.execute("DELETE from LogIn");
}
static String[] getLogIn() throws Exception
{
String get[]=new String[3];
ResultSet rs=s.executeQuery("Select * from LogIn");
while(rs.next())
{
for(int i=1;i<=3;i++)
get[i-1]=rs.getString(i);
//System.out.print("\n"+rs.getString(i));
}
return get;
}
static boolean isDatabaseBlank() throws Exception
{
ResultSet rs=s.executeQuery("Select * from LogIn");
String get[]=DataConnection.getLogIn();
int i;
for(i=0;i<3;i++)
if(get[i]!=null)
break;
if(i==3)
return true;
else
return false;

}
static void close() throws Exception
{
c.close();
}

}
 Back End Handler :

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;
public class BackEndHandler extends Thread
{
public static final short EMBED_MESSAGE= 0;
public static final short EMBED_FILE= 1;
public static final short RETRIEVE_MESSAGE= 2;
public static final short RETRIEVE_FILE= 3;
public static final short EDIT_MASTER= 4;
private short operation;
private WindowAdapter client;
private JFileChooser fileChooser;
private MyFileView fileView;
private File masterFile, dataFile, outputFile;
private int result, result2;
public BackEndHandler(WindowAdapter client, short operation)
{
this.client= client;
this.operation= operation;
// Setup file chooser
fileChooser= new JFileChooser("./");
fileChooser.setFileSelectionMode(fileChooser.FILES_ONLY);
fileChooser.setDialogType(fileChooser.CUSTOM_DIALOG);
//MyFileView fileView = new MyFileView();
//fileView.putIcon("jpg", new ImageIcon("Images/image.jpg"));
//fileView.putIcon("gif", new ImageIcon("Images/image.jpg"));
//fileView.putIcon("bmp", new ImageIcon("Images/image.jpg"));
//fileChooser.setFileView(fileView);
fileChooser.setAccessory(new FilePreviewer(fileChooser));
// Create and set the file filter
MyFileFilter filter1= new MyFileFilter(new String[]{"bmp", "jpg",
"gif", "tif"}, "Picture files");
MyFileFilter filter2= new MyFileFilter(new String[]{"mp3",
"wav", "ram", "wma"}, "Audio files");
MyFileFilter filter3= new MyFileFilter(new String[]{"mpg",
"wmv", "dat","mp4"}, "Video files");
fileChooser.addChoosableFileFilter(filter1);
fileChooser.addChoosableFileFilter(filter2);
fileChooser.addChoosableFileFilter(filter3);
}
public void run()
{
if(!chooseMasterFile()) return;
if(operation== EMBED_MESSAGE || operation==
EMBED_FILE)
if(!chooseOutputFile()) return;
if(operation== EMBED_FILE)
if(!chooseDataFile()) return;
SteganoInformation steg;
switch(operation)
{
case EMBED_MESSAGE: new EmbedMessageGUI(this);
break;
case EMBED_FILE: new EmbedFileGUI(this);
break;
case RETRIEVE_MESSAGE:
steg= new SteganoInformation(masterFile);
if(steg.isEster())
showEster(steg);
else
if(!steg.isValid())

JOptionPane.showMessageDialog(null, "File '"+ masterFile.getName()+


"' does not contain any
message or file\nembedded using Seganograph", "Invalid Steganograph
file!", JOptionPane.WARNING_MESSAGE);
else
new PreRetrieveGUI(steg,
PreRetrieveGUI.RETRIEVE_MESSAGE);
break;
case RETRIEVE_FILE:
steg= new SteganoInformation(masterFile);
if(steg.isEster())
showEster(steg);
else
if(!steg.isValid())
JOptionPane.showMessageDialog(null, "File '"+ masterFile.getName()+
"' does not contain any
message or file\nembedded using Seganograph", "Invalid Steganograph
file!", JOptionPane.WARNING_MESSAGE);
else
new PreRetrieveGUI(steg,
PreRetrieveGUI.RETRIEVE_FILE);
}
}
// Method for choosing input file
public boolean chooseMasterFile()
{
int result;
do
{
result= fileChooser.showDialog(null, "Select Master file");
if(result== fileChooser.APPROVE_OPTION)
{
masterFile= fileChooser.getSelectedFile();
if(!checkFileExistency(masterFile))
continue;
else
break;
}
} while(result!= fileChooser.CANCEL_OPTION);
if(result== fileChooser.CANCEL_OPTION) return false;
else return
true;
}
// Method for choosing output file
public boolean chooseOutputFile()
{
int result;
do
{
File previousFile= fileChooser.getSelectedFile();
result= fileChooser.showDialog(null, "Select Output file");
if(result== fileChooser.APPROVE_OPTION)
{
outputFile= fileChooser.getSelectedFile();
if(outputFile.exists())
{
result2= JOptionPane.showConfirmDialog(null,
"File "+ outputFile.getName()+ " already exists!\nWould you like to
OVERWRITE it?", "File already exists!", JOptionPane.YES_NO_OPTION);
if(result2== JOptionPane.NO_OPTION)
{
if(previousFile!= null)

fileChooser.setSelectedFile(previousFile);
continue;
}
}
break;
}
} while(result!= fileChooser.CANCEL_OPTION);
if(result== fileChooser.CANCEL_OPTION) return false;
else return
true;
}
// Method for choosing data file
public boolean chooseDataFile()
{
do
{
result= fileChooser.showDialog(null, "Select Data file");
if(result== fileChooser.APPROVE_OPTION)
{
dataFile= fileChooser.getSelectedFile();
if(!checkFileExistency(dataFile))
continue;
else
break;
}
} while(result!= fileChooser.CANCEL_OPTION);
if(result== fileChooser.CANCEL_OPTION) return false;
else return
true;
}
// Accessor methods
public File getMasterFile() { return masterFile; }
public File getOutputFile() { return outputFile; }
public File getDataFile() { return dataFile; }
// Mutator methods
public void setMasterFile(File file) { masterFile= file; }
public void setOutputFile(File file) { outputFile= file; }
public void setDataFile(File file) { dataFile= file; }
// Checks whether given file actually exists
private boolean checkFileExistency(File file)
{
if(!file.exists())
{
JOptionPane.showMessageDialog(null, "File "+
file.getName()+ " does not exist!", "Inexistent file!",
JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
private void showMessage(String message, String title)
{
JOptionPane.showMessageDialog(null, message, title,
JOptionPane.WARNING_MESSAGE);
}
private void showEster(SteganoInformation steg)
{
Object message[]= new Object[3];
message[0]= new MyJLabel("This is an encrypted zone.",
Color.red, Color.gray);
message[1]= new JLabel("Please enter password to continue.");
JPasswordField pass= new JPasswordField(10);
message[2]= pass;
String options[]= {"Retrieve now", "Cancel"};
int result= JOptionPane.showOptionDialog(null, message,
"Encrypted zone"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
if(result== 1) return;
String password= new String(pass.getPassword());
if(password.length()<8)
JOptionPane.showMessageDialog(null, "This was not the
right password!", "Invalid password", JOptionPane.OK_OPTION);
else
{
int fileSize= (int) steg.getFile().length();
byte[] byteArray= new byte[fileSize];
try
{
DataInputStream in= new DataInputStream(new
FileInputStream(steg.getFile()));
in.read(byteArray, 0, fileSize);
in.close();
Cipher cipher= Cipher.getInstance("DES");
cipher.init(Cipher.DECRYPT_MODE, new
SecretKeySpec(password.substring(0, 8).getBytes(), "DES"));
byteArray= cipher.doFinal(byteArray);
}
catch(Exception e) { return; }

JFrame frame= new JFrame("Enjoy the ester egg...");


frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.getContentPane().add(new JScrollPane(new
JLabel(new ImageIcon(byteArray))));
frame.setBackground(Color.white);
Dimension d= Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize(d.width, d.height/2);
frame.setVisible(true);
}
}
}

Code Analysis
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace Text2Image
{
public partial class FrmSteganography : Form
{
public FrmSteganography()
{
InitializeComponent();
}

//public values:
string loadedTrueImagePath, loadedFilePath,
saveToImage,DLoadImagePath,DSaveFilePath;
int height, width;
long fileSize, fileNameSize;
Image loadedTrueImage, DecryptedImage ,AfterEncryption;
Bitmap loadedTrueBitmap, DecryptedBitmap;
Rectangle previewImage = new Rectangle(20,160,490,470);
bool canPaint = false, EncriptionDone = false;
byte[] fileContainer;

private void EnImageBrowse_btn_Click(object sender, EventArgs e)


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
loadedTrueImagePath = openFileDialog1.FileName;
EnImage_tbx.Text = loadedTrueImagePath;
loadedTrueImage = Image.FromFile(loadedTrueImagePath);
height = loadedTrueImage.Height;
width = loadedTrueImage.Width;
loadedTrueBitmap = new Bitmap(loadedTrueImage);

FileInfo imginf = new FileInfo(loadedTrueImagePath);


float fs = (float)imginf.Length / 1024;
ImageSize_lbl.Text = smalldecimal(fs.ToString(), 2) + "
KB";
ImageHeight_lbl.Text = loadedTrueImage.Height.ToString() +
" Pixel";
ImageWidth_lbl.Text = loadedTrueImage.Width.ToString() + "
Pixel";
double cansave = (8.0 * ((height * (width / 3) * 3) / 3 -
1)) / 1024;
CanSave_lbl.Text = smalldecimal(cansave.ToString(), 2) + "
KB";

canPaint = true;
this.Invalidate();
}
}

private string smalldecimal(string inp, int dec)


{
int i;
for (i = inp.Length - 1; i > 0; i--)
if (inp[i] == '.')
break;
try
{
return inp.Substring(0, i + dec + 1);
}
catch
{
return inp;
}
}

private void EnFileBrowse_btn_Click(object sender, EventArgs e)


{
if (openFileDialog2.ShowDialog() == DialogResult.OK)
{
loadedFilePath = openFileDialog2.FileName;
EnFile_tbx.Text = loadedFilePath;
FileInfo finfo = new FileInfo(loadedFilePath);
fileSize = finfo.Length;
fileNameSize = justFName(loadedFilePath).Length;
}
}

private void Encrypt_btn_Click(object sender, EventArgs e)


{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
saveToImage = saveFileDialog1.FileName;
}
else
return;
if (EnImage_tbx.Text == String.Empty || EnFile_tbx.Text ==
String.Empty)
{
MessageBox.Show("Encrypton information is
incomplete!\nPlease complete them frist.", "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
if (8*((height * (width/3)*3)/3 - 1) < fileSize + fileNameSize)
{
MessageBox.Show("File size is too large!\nPlease use a
larger image to hide this file.", "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
fileContainer = File.ReadAllBytes(loadedFilePath);
EncryptLayer();
}

private void EncryptLayer()


{
toolStripStatusLabel1.Text ="Encrypting... Please wait";
Application.DoEvents();
long FSize = fileSize;
Bitmap changedBitmap = EncryptLayer(8, loadedTrueBitmap, 0,
(height * (width/3)*3) / 3 - fileNameSize - 1, true);
FSize -= (height * (width / 3) * 3) / 3 - fileNameSize - 1;
if(FSize > 0)
{
for (int i = 7; i >= 0 && FSize > 0; i--)
{
changedBitmap = EncryptLayer(i, changedBitmap, (((8 -
i) * height * (width / 3) * 3) / 3 - fileNameSize - (8 - i)), (((9 - i) *
height * (width / 3) * 3) / 3 - fileNameSize - (9 - i)), false);
FSize -= (height * (width / 3) * 3) / 3 - 1;
}
}
changedBitmap.Save(saveToImage);
toolStripStatusLabel1.Text = "Encrypted image has been
successfully saved.";
EncriptionDone = true;
AfterEncryption = Image.FromFile(saveToImage);
this.Invalidate();
}

private Bitmap EncryptLayer(int layer, Bitmap inputBitmap, long


startPosition, long endPosition, bool writeFileName)
{
Bitmap outputBitmap = inputBitmap;
layer--;
int i = 0, j = 0;
long FNSize = 0;
bool[] t = new bool[8];
bool[] rb = new bool[8];
bool[] gb = new bool[8];
bool[] bb = new bool[8];
Color pixel = new Color();
byte r, g, b;

if (writeFileName)
{
FNSize = fileNameSize;
string fileName = justFName(loadedFilePath);

//write fileName:
for (i = 0; i < height && i * (height / 3) < fileNameSize;
i++)
for (j = 0; j < (width / 3) * 3 && i * (height / 3) +
(j / 3) < fileNameSize; j++)
{
byte2bool((byte)fileName[i * (height / 3) + j / 3],
ref t);
pixel = inputBitmap.GetPixel(j, i);
r = pixel.R;
g = pixel.G;
b = pixel.B;
byte2bool(r, ref rb);
byte2bool(g, ref gb);
byte2bool(b, ref bb);
if (j % 3 == 0)
{
rb[7] = t[0];
gb[7] = t[1];
bb[7] = t[2];
}
else if (j % 3 == 1)
{
rb[7] = t[3];
gb[7] = t[4];
bb[7] = t[5];
}
else
{
rb[7] = t[6];
gb[7] = t[7];
}
Color result = Color.FromArgb((int)bool2byte(rb),
(int)bool2byte(gb), (int)bool2byte(bb));
outputBitmap.SetPixel(j, i, result);
}
i--;
}
//write file (after file name):
int tempj = j;

for (; i < height && i * (height / 3) < endPosition -


startPosition + FNSize && startPosition + i * (height / 3) < fileSize +
FNSize; i++)
for (j = 0; j < (width / 3) * 3 && i * (height / 3) + (j /
3) < endPosition - startPosition + FNSize && startPosition + i * (height /
3) + (j / 3) < fileSize + FNSize; j++)
{
if (tempj != 0)
{
j = tempj;
tempj = 0;
}
byte2bool((byte)fileContainer[startPosition + i *
(height / 3) + j / 3 - FNSize], ref t);
pixel = inputBitmap.GetPixel(j, i);
r = pixel.R;
g = pixel.G;
b = pixel.B;
byte2bool(r, ref rb);
byte2bool(g, ref gb);
byte2bool(b, ref bb);
if (j % 3 == 0)
{
rb[layer] = t[0];
gb[layer] = t[1];
bb[layer] = t[2];
}
else if (j % 3 == 1)
{
rb[layer] = t[3];
gb[layer] = t[4];
bb[layer] = t[5];
}
else
{
rb[layer] = t[6];
gb[layer] = t[7];
}
Color result = Color.FromArgb((int)bool2byte(rb),
(int)bool2byte(gb), (int)bool2byte(bb));
outputBitmap.SetPixel(j, i, result);

}
long tempFS = fileSize, tempFNS = fileNameSize;
r = (byte)(tempFS % 100);
tempFS /= 100;
g = (byte)(tempFS % 100);
tempFS /= 100;
b = (byte)(tempFS % 100);
Color flenColor = Color.FromArgb(r,g,b);
outputBitmap.SetPixel(width - 1, height - 1, flenColor);

r = (byte)(tempFNS % 100);
tempFNS /= 100;
g = (byte)(tempFNS % 100);
tempFNS /= 100;
b = (byte)(tempFNS % 100);
Color fnlenColor = Color.FromArgb(r,g,b);
outputBitmap.SetPixel(width - 2, height - 1, fnlenColor);

return outputBitmap;
}

private void DecryptLayer()


{
toolStripStatusLabel1.Text = "Decrypting... Please wait";
Application.DoEvents();
int i, j = 0;
bool[] t = new bool[8];
bool[] rb = new bool[8];
bool[] gb = new bool[8];
bool[] bb = new bool[8];
Color pixel = new Color();
byte r, g, b;
pixel = DecryptedBitmap.GetPixel(width - 1, height - 1);
long fSize = pixel.R + pixel.G * 100 + pixel.B * 10000;
pixel = DecryptedBitmap.GetPixel(width - 2, height - 1);
long fNameSize = pixel.R + pixel.G * 100 + pixel.B * 10000;
byte[] res = new byte[fSize];
string resFName = "";
byte temp;

//Read file name:


for (i = 0; i < height && i * (height / 3) < fNameSize; i++)
for (j = 0; j < (width / 3) * 3 && i * (height / 3) + (j /
3) < fNameSize; j++)
{
pixel = DecryptedBitmap.GetPixel(j, i);
r = pixel.R;
g = pixel.G;
b = pixel.B;
byte2bool(r, ref rb);
byte2bool(g, ref gb);
byte2bool(b, ref bb);
if (j % 3 == 0)
{
t[0] = rb[7];
t[1] = gb[7];
t[2] = bb[7];
}
else if (j % 3 == 1)
{
t[3] = rb[7];
t[4] = gb[7];
t[5] = bb[7];
}
else
{
t[6] = rb[7];
t[7] = gb[7];
temp = bool2byte(t);
resFName += (char)temp;
}
}

//Read file on layer 8 (after file name):


int tempj = j;
i--;

for (; i < height && i * (height / 3) < fSize + fNameSize; i++)


for (j = 0; j < (width / 3) * 3 && i * (height / 3) + (j /
3) < (height * (width / 3) * 3) / 3 - 1 && i * (height / 3) + (j / 3) <
fSize + fNameSize; j++)
{
if (tempj != 0)
{
j = tempj;
tempj = 0;
}
pixel = DecryptedBitmap.GetPixel(j, i);
r = pixel.R;
g = pixel.G;
b = pixel.B;
byte2bool(r, ref rb);
byte2bool(g, ref gb);
byte2bool(b, ref bb);
if (j % 3 == 0)
{
t[0] = rb[7];
t[1] = gb[7];
t[2] = bb[7];
}
else if (j % 3 == 1)
{
t[3] = rb[7];
t[4] = gb[7];
t[5] = bb[7];
}
else
{
t[6] = rb[7];
t[7] = gb[7];
temp = bool2byte(t);
res[i * (height / 3) + j / 3 - fNameSize] = temp;
}
}

//Read file on other layers:


long readedOnL8 = (height * (width/3)*3) /3 - fNameSize - 1;

for (int layer = 6; layer >= 0 && readedOnL8 + (6 - layer) *


((height * (width / 3) * 3) / 3 - 1) < fSize; layer--)
for (i = 0; i < height && i * (height / 3) + readedOnL8 +
(6 - layer) * ((height * (width / 3) * 3) / 3 - 1) < fSize; i++)
for (j = 0; j < (width / 3) * 3 && i * (height / 3) +
(j / 3) + readedOnL8 + (6 - layer) * ((height * (width / 3) * 3) / 3 - 1) <
fSize; j++)
{
pixel = DecryptedBitmap.GetPixel(j, i);
r = pixel.R;
g = pixel.G;
b = pixel.B;
byte2bool(r, ref rb);
byte2bool(g, ref gb);
byte2bool(b, ref bb);
if (j % 3 == 0)
{
t[0] = rb[layer];
t[1] = gb[layer];
t[2] = bb[layer];
}
else if (j % 3 == 1)
{
t[3] = rb[layer];
t[4] = gb[layer];
t[5] = bb[layer];
}
else
{
t[6] = rb[layer];
t[7] = gb[layer];
temp = bool2byte(t);
res[i * (height / 3) + j / 3 + (6 - layer) *
((height * (width / 3) * 3) / 3 - 1) + readedOnL8] = temp;
}
}

if (File.Exists(DSaveFilePath + "\\" + resFName))


{
MessageBox.Show("File \"" + resFName + "\" already exist
please choose another path to save file",
"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
else
File.WriteAllBytes(DSaveFilePath + "\\" + resFName, res);
toolStripStatusLabel1.Text = "Decrypted file has been
successfully saved.";
Application.DoEvents();
}

private void byte2bool(byte inp, ref bool[] outp)


{
if(inp>=0 && inp<=255)
for (short i = 7; i >= 0; i--)
{
if (inp % 2 == 1)
outp[i] = true;
else
outp[i] = false;
inp /= 2;
}
else
throw new Exception("Input number is illegal.");
}

private byte bool2byte(bool[] inp)


{
byte outp = 0;
for (short i = 7; i >= 0; i--)
{
if (inp[i])
outp += (byte)Math.Pow(2.0, (double)(7-i));
}
return outp;
}

private void Decrypt_btn_Click(object sender, EventArgs e)


{

if (DeSaveFile_tbx.Text == String.Empty || DeLoadImage_tbx.Text


== String.Empty)
{
MessageBox.Show("Text boxes must not be empty!", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);

return;
}

if (System.IO.File.Exists(DeLoadImage_tbx.Text) == false)
{
MessageBox.Show("Select image file.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
DeLoadImage_tbx.Focus();
return;
}

DecryptLayer();
}

private void DeLoadImageBrowse_btn_Click(object sender, EventArgs


e)
{
if (openFileDialog3.ShowDialog() == DialogResult.OK)
{
DLoadImagePath = openFileDialog3.FileName;
DeLoadImage_tbx.Text = DLoadImagePath;
DecryptedImage = Image.FromFile(DLoadImagePath);
height = DecryptedImage.Height;
width = DecryptedImage.Width;
DecryptedBitmap = new Bitmap(DecryptedImage);

FileInfo imginf = new FileInfo(DLoadImagePath);


float fs = (float)imginf.Length / 1024;
ImageSize_lbl.Text = smalldecimal(fs.ToString(), 2) + "
KB";
ImageHeight_lbl.Text = DecryptedImage.Height.ToString() + "
Pixel";
ImageWidth_lbl.Text = DecryptedImage.Width.ToString() + "
Pixel";
double cansave = (8.0 * ((height * (width / 3) * 3) / 3 -
1)) / 1024;
CanSave_lbl.Text = smalldecimal(cansave.ToString(), 2) + "
KB";

canPaint = true;
this.Invalidate();
}
}

private void DeSaveFileBrowse_btn_Click(object sender, EventArgs e)


{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
DSaveFilePath = folderBrowserDialog1.SelectedPath;
DeSaveFile_tbx.Text = DSaveFilePath;
}
}

private void Form1_Paint(object sender, PaintEventArgs e)


{
if(canPaint)
try
{
if (!EncriptionDone)
e.Graphics.DrawImage(loadedTrueImage,
previewImage);
else
e.Graphics.DrawImage(AfterEncryption,
previewImage);
}
catch
{
e.Graphics.DrawImage(DecryptedImage, previewImage);
}
}

private string justFName(string path)


{
string output;
int i;
if (path.Length == 3) // i.e: "C:\\"
return path.Substring(0, 1);
for (i = path.Length - 1; i > 0; i--)
if (path[i] == '\\')
break;
output = path.Substring(i + 1);
return output;
}

private string justEx(string fName)


{
string output;
int i;
for (i = fName.Length - 1; i > 0; i--)
if (fName[i] == '.')
break;
output = fName.Substring(i + 1);
return output;
}

private void Close_btn_Click(object sender, EventArgs e)


{
this.Close();
}

private void linkLabel1_LinkClicked(object sender,


LinkLabelLinkClickedEventArgs e)
{

System.Diagnostics.Process.Start("http:\\\\www.programmer2programmer.net");

}
}
Program Description
Add Data Source (Required To Run the Project)

 Start Control Panel from Start menu.


 Inside Control Panel, Double Click on Administrative Tools
 Then Double Click on Data Source (ODBC).

 An ODBC Data Source Administrator Dialog will open.

 Inside it make sure that User DNS tab is selected.


 Then click on Add or press “Alt+D”.

 A Create New Data Source Dialog will open. In it select SQL Server(*.db)
 Click on Finish. An ODBC SQL Server Setup Dialog will open.

 Give Data Source Name as “Connection” (without quotes).


 Click on Select and locate the database file named as login which is
available inside Stenography Directory. Press on OK.
 Press on OK to close the ODBC Data Source Administrator
Dialog.

 That’s it! The database is now added to the data source.


 SPLASHSCREEN FORM :

START UP FORM:

This form is use to open a username login by creating this process.


Login System:

 Type the login name as “admin” and password as “pass” without quotes .
 You can change the default login name and password from settings menu.
 Click on login button as below.
MDI PARENT :

THIS THE MDI PARENT FORM .ALL THE LINKS OF OTHER FORMS
ARE GIVEN FROM THIS MDI THROUGHPROJECT.
How to Embed Message:
Step 1:
 Click on 'Embed Message' button or choose File > Embed Message from the
menu.

 In this form information about how to embed the message.

 Select the Master file which will be used for embedding data into.
Step 2:

 Select the Output file which will contain the embedded message. This file
will be an a copy of master file and will containing the embedded message.
Step 3:
 In the 'Embedding message' dialog box, Key in the message in the message
box or paste a text already present on the clipboard.
 Choose the options to be used while embedding message. These options
include Compression and Encryption.

 If you specify compression to be used, you can specify the compression level
to be used between 0 to 9.
 If you specify encryption to be used, you'll have to specify a password which
is a minimum of 8 characters in length.
 You can change the Master file or Output file by clicking on 'Change' button
next to each item.
Step 4:

 If the Message is successfully Embedded a “Message embedded successfully


in the file” message will appear .
 How to Retrieve Message:

Step 1:
 Click on 'Retrieve Message' button or choose File > Retrieve Message from
the menu.

 Select the Master file containing the embedded message.


STEP 2:

 A dialog box will appear summarizing the properties of the Master file.

 It shows you whether the file contains an embedded message or a file,


Steganograph version used to embed the message/file, whether compression
and encryption have been used and the compression ratio if compression has
been used. It also shows you the request you have made.

 Finally when you're ready to go, click on 'Go' button.


STEP 3:
 If the message is encrypted, you will be asked for the password. Key in the
password and click on the ‘Retrieve now’ button.

 Finally get a Retrieve message from the file.


How to Embed File:
Step 1:
 Click on 'Embed File' button or choose File > Embed File from the menu.

 In this form information about how to embed the file.

 Select the Master file which will be used for embedding data into.
Step 2:
 Select the ‘Output file’ which will contain the embedded Data file.

 This file will be an a copy of master file and will containing the embedded
Data file.
Step 3:
 Select the ‘Data file’ which will contain the embedded Data file.
Step 4:
 In the 'Embedding message' dialog box, Key in the file in the message box or
paste a text already present on the clipboard.
 Choose the options to be used while embedding file. These options include
Compression and Encryption.

 If you specify compression to be used, you can specify the compression level
to be used between 0 to 9.
 If you specify encryption to be used, you'll have to specify a password which
is a minimum of 8 characters in length.
 You can change the Master file or Output file by clicking on 'Change' button
next to each item.
 If the File is successfully Embedded a “Master Fileembedded successfully
in the Output file” message will appear .
How to Retrieve File:
Step 1:

 Click on 'Retrieve File' button or choose File > Retrieve File from the menu.

 Select the Master file containing the embedded file.


STEP 2:

 A dialog box will appear summarizing the properties of the Master file.

 It shows you whether the file contains an embedded a file, Steganograph


version used to embed the file, whether compression and encryption have
been used and the compression ratio if compression has been used. It also
shows you the request you have made.

 Finally when you're ready to go, click on 'Go' button.


STEP 3:
 If the message is encrypted, you will be asked for the password. Key in the
password and click on the ‘Retrieve now’ button.

 The file will be retrieved and stored in current working directory. If it is


detected that you are using a Windows platform, you will have a choice to
open the file directly from the application.
 Finally get a Embed File from the Retreive file.
User Manual
This is the first screen which has two tab options – one is Encrypt Image for
encryption and another is Decrypt image for decryption. In right – top panel
is displays the information about the image such as size, height and width.

Encryption
1. For Encryption select Encrypt Image tab option.

2. For load image click on button “Browse” that is next to the Load Image
textbox. The file open dialog box will displays as follows, select the Image file,
which you want to use hide information and click on Open button.
1. The image file will opened and is displays as follows. Next, click on
“Browse” button that is next to the Load File textbox.
2. Again the file open dialog box will appear, select any type of file
whatever you want to hide with the image and click on ok button.
3. The next step is to encrypt the file. Now click on “Encrypt” button, it
will open the save dialog box which ask you to select the path to save
the New image file and the Image file name. The default format of
image file is BMP.
Decryption

1. Select the Decryption Image tab option.


2. Next click on the “Browse” button, which open the Open file dialog box, here
you have to select the image which is Encrypted and has hidden information
file. Select the image file and click on Open button.
3. The image file displayed as follows:
4. Now click on “Browse” button which is next to “Save file to” textbox. It will
open a dialog box that is “Browse for folder”. It ask you to select the path or
folder, where you want to extract the hidden file. Select the folder and click on
Ok button.

5. Now click on Decrypt button, it will decrypt the image, the hidden file and
image file is saved into selected folder. The message for successful decryption
is displayed on the status bar which is places at bottom of the screen.
System Implementstion
I. VALIDATION TESTING:

Software validation is achieved through different tests that demonstrate


conformity with requirements. In general, validation is the process of checking
if something satisfied a certain criteria. Validation implies one is able to
document that a solution or process is correct or suited for its intended use.

Validation can be too declared or make legally valid or to prove valid or


conform the validity of data, information or process.

Validation is important because it disallow data that can not possibly be


either true or real to be entered into database or computer system.

The methodology used for maintaining data integrity is as follows:

1] Numeric validation:

In this validation we are checking range of age, contact number, negative


numbering or age.

2] Data validation:

In this validation we not allow to enter wrong data like spaces before any
data, departure date should not less than booking date, no special character in
data, and length of character is fix, etc..

In our system we are going to use the Black box testing in the following
criteria.
1] Easy to compute data:

Ensure legitimate values which the system should accept and save in the
database or process the data to display any of the required results. We ensured
that the system accepted and proposed all such data and give required results.

2] Extreme data testing:

This test case carried out data overflow and underflow checks to make
sure that the data lies within the available set of data range for that particular
data type and the particular data field e.g. an integer input should lies between
32768 and 32767, company code is a four digit positive number etc.

3] Invalid inconsistent database input:

When primary key values were entered it was checked whether they
conflicted with existing values. When foreign key values were entered they
were validated for referential integrity violations.
II. SECURITY TESTING:

 Login screen provides access too only authorized employee using a user
password combination. So we provide the encryption of password before
storing in the database.
 During security testing, the tester plays the important role of an individual
who desires to penetrate the system.
 He tester may attempt to acquire password through external clerical means
may attack the system with custom software designed to break down any
defenses that have been constructed.

III. END USER TESTING:

In this software the performance has been inline with the expectations of
the client company. This phase in our software accomplishes:

1) Corrective faults
2) Improved performance.
3) Adapt the product to a changed environment and implementing changes.
4) Evaluation by the external guide.
Testing is done to find information critical decisions about the project or
product that are made on basic of the information.

Testing is process of executing program with the intent of finding error


FUTURE ENHANSMENT

FUTURE SCOPE

 I hope to add support to hide all file formats. This allows for a much
broaderspectrum of uses: one would be able to encode .exe, .batch etc.
 Theprogram would be more versatile because often hiding text just isn’t
enough.
 I also would like to implement batch image processing and statistical
analysis sothat I can run the program through a dataset of images and detect
Steganographyand perhaps crawl through Google Image Search to see how
prevalentSteganography is.
 I eventually plan to port the program to use C/C++ so that I may take
advantage ofbit-fields in C and learn to code GUI’s as well.
 I have a plug-in handler developed forC++ that I would like to use in this
project so that third-party developers maycontribute to the project.
 More than one company can be integrated through this software.
 Distributed database approach in place of centralized system.
Summary

Steganography is a really interesting subject and outside of the mainstream


cryptography and system administration that most of us deal with day after day.

Steganography can be used for hidden communication. We have explored the limits
of steganography theory and practice. We printed out the enhancement of the image
steganography system using LSB approach to provide a means of secure
communication. A stego-key has been applied to the system during embedment of
the message into the cover image.

This steganography application software provided for the purpose to how to use any
type of image formats to hiding any type of files inside their. The master work of this
application is in supporting any type of pictures without need to convert to bitmap,
and lower limitation on file size to hide, because of using maximum memory space
in pictures to hide the file.

Since ancient times, man has found a desire in the ability to communicate covertly.
The recent explosion of research in watermarking to protect intellectual property is
evidence that steganography is not just limited to military or espionage applications.
Steganography, like cryptography, will play an increasing role in the future of secure
communication in the “digital world”.
References & Bibliography
BIBLIOGRAPHY

 REFERENCES BOOK :

1: An Overview of Steganography for the Computer Forensics Examiner,


Burlington, 2004.
-- Kesslet, Gary C

2: A Review of Data Hiding In Digital Images, West Lafayette, 1999.


--Lin, Eugene and Edward Delp

3: Discovering Hidden Evidence, Cortland, 2006.


--Hosmer, Chet.

4: Stegnography Of LSB Encoding In Color Images, Binghamton,2007


-- Fridrich, J., R. Du, M.Long

 REFERENCES SITE :

The following websites were referred for help :

 www.google.com

 www.w3school.com

 www.leafraker.com/DCE

 http://www.google.com

 http://www.microsoft.com

 http://www.programmer2programmer.net

 http://www.codeproject.com
 http://www.asp.net

 http://www.asp123.com

 http://www.wikipedia.org