Beruflich Dokumente
Kultur Dokumente
PROJECT REPORT
ON
Steganography
Submitted to
UNIVERSITY OF MUMBAI
ICLES'
MOTILAL JHUNJHUNWALA COLLEGE
Steganography
Undertaken by
Atul Mahendra Vasave
Lastly I would like to thank all those who directly and indirectly helped in
completion of this project.
2. 2 System Analysis
2.2 c) ERD
3. 3 System Design
4. 4 System Coding
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 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.
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?
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:
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
This technique is chosen, because this system includes not only imperceptibility but
also un-delectability by any steganolysis tool.
LIMITATIONS
FEATURES
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.
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:
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
User name
Password
ADMIN
Select the Master file
To get a Message
RETRIEVE
MESSAGE
Select the Master file
EMBED FILE
Specify Compression and encryption to
use
booking
report
Select the Master file
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
Output File
Master Output Data
File File File
Secrete Key
Login the
applicatio
n
Embed file
Retrieve file
Embed Message
Retrieve Message
Embed Message Retrieve Message
Choose
Master file
Choose
Master file
Compress &
Encrypted file
SEQUENCE DIAGRAM
Embed Retrieve
File File
User
Master file
Data File
To get a file
Embed Retrieve
Message Message
User
Master file
Type Message
To get a Message
SYSTEM FLOW CHART
STRUCTURE CHART
Stenography
Master Master
Master file Add branch
file file
and modify
Output
file
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.
Encryption Decryption
BMP FILE
Decryption Process
BMP FILE
Stenography
Encrypted File
Select Output 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).
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;
int value=0;
FontMetrics fm;
JTextField EntLogin;
JPasswordField EntPass;
JLabel Hnt;
String getInfo[];
fm=g.getFontMetrics(SecChkFont);
super(title);
setSize(400,300);
repaint();
Container c=getContentPane();
c.setLayout(null);
setResizable(false);
setIconImage(new ImageIcon("FSPIcon.jpg").getImage());
Hnt=new JLabel(HntIcon);
EntLogin=new JTextField(20);
EntPass=new JPasswordField(20);
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);
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()
setVisible(false);
System.exit(1);
});
LogIn.addActionListener(this);
try
{
DataConnection.getConnection();
getInfo=DataConnection.getLogIn();
System.out.print("\nCome In");
if(DataConnection.isDatabaseBlank())
//mc.setVisible(true);
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]);
{
if(ae.getActionCommand().equals("Login"))
if(EntLogin.getText().length()==0 || EntPass.getText().length()==0)
EntLogin.setText("");
EntPass.setText("");
else
if(!(EntLogin.getText().equals(getInfo[0]) &&
EntPass.getText().equals(getInfo[1])))
EntLogin.setText("");
EntPass.setText("");
else
//setVisible(true);
//setVisible(false);
}
}
try{
DataConnection.getConnection();
boolean isDatabaseBlank=DataConnection.isDatabaseBlank();
DataConnection.close();
if(isDatabaseBlank){
DataConnection.close();
mf.setVisible(true);
else{
DataConnection.close();
obj.setVisible(true);
catch(Exception e){
}*/
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;
{
private JFrame mainFrame;
public MainClient()
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.addWindowListener(this);
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.add(mnuEmbedMessage);
menuFile.add(mnuEmbedFile);
menuFile.add(mnuRetrieveMessage);
menuFile.add(mnuRetrieveFile);
menuFile.add(mnuExit);
menuEdit.add(mnuModifyMaster);
menuHelp= new MyJMenu("Help", 0, 'h');
menuHelp.add(mnuHelp);
menuHelp.add(mnuAbout);
menuBar.add(menuFile);
//menuBar.add(menuEdit);
menuBar.add(menuHelp);
mainFrame.setJMenuBar(menuBar);
panelAbout.setLayout(gbl);
panelAbout.setBackground(Color.white);
panelButtons.setBackground(Color.white);
panelButtons.setLayout(gbl);
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
panelButtons.add(lblFiller[0]);
panelButtons.add(btnHelp);
panelButtons.add(btnAbout);
gbc.fill = gbc.BOTH;
panelButtons.add(lblFiller[1]);
gbc.fill= gbc.NONE;
panelButtons.add(btnEmbedMessage);
panelButtons.add(btnRetrieveMessage);
panelButtons.add(lblFiller[2]);
gbc.fill= gbc.NONE;
panelButtons.add(btnEmbedFile);
panelButtons.add(btnRetrieveFile);
mainPanel.setLayout(gbl);
mainPanel.setBackground(Color.white);
gbc.anchor= gbc.CENTER;
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]);
tempPanel.add(mainPanel, BorderLayout.CENTER);
Dimension d= Toolkit.getDefaultToolkit().getScreenSize();
mainFrame.setResizable(false);
mainFrame.setVisible(true);
// Listener methods
{
back= new BackEndHandler(this, BackEndHandler.EMBED_MESSAGE);
back.start();
back.start();
back.start();
back.start();
back.start();
Steganograph.showHelpDialog();
Steganograph.showAboutDialog();
if(source== mnuExit)
if(result== JOptionPane.YES_OPTION)
System.exit(0);
{
JOptionPane.showMessageDialog(mainFrame, "Thanks for using this
Steganograph.", "Confirm Exit", JOptionPane.INFORMATION_MESSAGE);
// Main method
//mc.setVisible(true);
//lg.setVisible(false);
) )
Start Screen:
import javax.swing.*;
import java.awt.*;
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{
try{
try{
startScreen.setVisible(false);
catch(Exception ee){ }
DataConnection.getConnection();
boolean
isDatabaseBlank=DataConnection.isDatabaseBlank();
DataConnection.close();
if(isDatabaseBlank)
DataConnection.close();
//mc.setVisible(true);
else{
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;
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;
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);
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);
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#");
}
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;
}
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});
info.setDataFile(dataFile);
if(dataFile.exists() && !overwrite)
{
message= "File Exists";
return false;
}
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);
}
byte2&= 0x03;
byte2<<= j;
byte1|= byte2;
}
bytes[i]= byte1;
}
}
private void retrieveBytes(byte[] bytes)
{
int size= bytes.length;
byte2&= 0x03;
byte2<<= j;
byte1|= byte2;
}
bytes[i]= byte1;
}
}
private void readBytes(byte[] bytes, byte[] array, int marker)
{
byteArray= array;
inputMarker= marker;
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;
}
if(fileExtension.equalsIgnoreCase("jpg"))
inputMarker= Steganograph.OFFSET_JPG;
else if(fileExtension.equalsIgnoreCase("png"))
inputMarker= Steganograph.OFFSET_PNG;
else
inputMarker=
Steganograph.OFFSET_GIF_BMP_TIF;
if(dataLength<0 || dataLength>file.length())
{
starter= "Invalid";
return;
}
else
starter= "Rakesh";
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);
}
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 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())
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; }
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;
canPaint = true;
this.Invalidate();
}
}
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;
}
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;
}
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();
}
canPaint = true;
this.Invalidate();
}
}
System.Diagnostics.Process.Start("http:\\\\www.programmer2programmer.net");
}
}
Program Description
Add Data Source (Required To Run the Project)
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.
START UP FORM:
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.
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:
Step 1:
Click on 'Retrieve Message' button or choose File > Retrieve Message from
the menu.
A dialog box will appear summarizing the properties of the Master 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.
A dialog box will appear summarizing the properties of the Master file.
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
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:
1] Numeric validation:
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.
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.
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.
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.
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 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 :
REFERENCES SITE :
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