You are on page 1of 95

STEGANOGRAPHY(Hidden Communication)

PROJECT REPORT 2015

A MINI PROJECT ON
STEGANOGRAPHY
(Hidden Communication)

A Project Work Submitted To


MAHATMA GANDHI UNIVERSITY,
KOTTAYAM
In partial fulfilment of the requirements for the award of degree in
BACHELOR OF COMPUTER SCIENCE

BY
ELDHOSE PAILY
Register No:130021026077
VIPIN .K .J
Register No:130021026089

Under the supervision of


Mrs ABINSHA SALMAN

DEPARTMENT OF COMPUTER SCIENCE


JAI BHARATH ARTS & SCIENCE COLLEGE
PERUMBAVOOR-683554

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

DEPARTMENT OF COMPUTER SCIENCE


JAI BHARATH ARTS & SCIENCE COLLEGE
PERUMBAVOOR-683554

CERTIFICATE
I hereby certify that this work entitled STEGANOGRAPHY HIDDEN
is benefited piece of research done by ELDHOSE PAILY (Reg
No:130021026077); VIPIN .K .J (Register No:130021026089) in partial
fulfilment requirement of the degree in Bachelor of Computer Science in Mahatma
Gandhi University under my guidance & supervision
COMMUNICATION

Mrs. ABINSHA SALMAN


( Project Guide )

Mrs. SAHALA. K. I
( Head of the Department )

Submitted for the viva Examination held on: _________________________

Internal Examiner:

External Examiner:

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

ACKNOWLEDGEMENT
At the outset, I thank God Almighty for making this
endeavour a success.
I express my gratitude to DR: K.X Varghese, principal of Jai Bharath
Arts and Science College, for providing me with adequate facilities, ways and means
by which I am able to complete the project work.
With immense pleasure I take this opportunity to record
my sincere thanks to my Guide Mrs. ABINSHA SALMAN , Asst Professor ,
Department of Computer Application , Jai bharath Arts and Science College,
Arackappady and for suggestions and modifications. I especially thank
Mrs.SAHALA. K .I, head of the department of jai bharath Arts and Science college,
for having shown been interest in the development of this project.
Last but not the least,
I also express my gratitude to all other members of the faculty and well-wishers who
assisted me in various occasion during the project work

ELDHOSE PAILY
VIPIN .K .J

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

INDEX
No

Contents

Page no

Introduction
1.1 Overview of project
1.2Organisation project

1
2
3

System Analysis
2.1 Introduction
2.2 Existing System
2.3 Proposed System
2.4 Feasibility Study
2.4.1 Economical Feasibility
2.4.2 Operational Feasibility
2.4.3 Technical Feasibility
2.4.4 Social Feasibility

4
6
6
7
8
8
9
9

2.5 System Specification


2.5.1 Hardware&Software Specification
2.5.2 Operating System
2.5.3 Overview of jsp

10
11
12
13

System Design
3.1 Process Design
3.2 Input Design
3.3 Output Design
3.4 Database Design
3.4.1 Table Design
3.4.2 Data Flow Diagram
System Testing
System Implementation &Security
System Mantenance
Future Enhancement

16
17
18
19
20
23
28
34
38
41
44

4
5
6
7

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

Conclusion

46

Bibliography

48

10

Appendix
10.1 Coding
10.2 Screen Shots

50
91

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

INTRODUCTION

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

INTRODUCTION

Steganography (pronounced STEHG-uh-NAH-gruhf-ee, from Greek steganos, or


"covered," andgraphie, or "writing") is the hiding of a secret message within an
ordinary message and the extraction of it at its destination. Steganography
takes cryptography a step farther by hiding an encrypted message so that no one
suspects it exists. Ideally, anyone scanning your data will fail to know it contains
encrypted data.
In modern digital steganography, data is first encrypted by the usual means and then
inserted, using a special algorithm, into redundant (that is, provided but unneeded)
data that is part of a particular file format such as a JPEG image. Think of all the bits
that represent the same color pixels repeated in a row. By applying the encrypted data
to this redundant data in some random or nonconspicuous way, the result will be data
that appears to have the "noise" patterns of regular, nonencrypted data. A trademark or
other identifying symbol hidden in software code is sometimes known as
a watermark.
Recently revived, this formerly obsolete term gained currency in its day (1500) from a
work by Johannes Trithemius, Steganographia, ostensibly a system of angel magic
but also claiming to include a synthesis of how to learn and know things contained

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

within a system of cryptography. The book was privately circulated but never
published by the author because those who read it found it rather fearsome.
Steganography is data hidden within data. Steganography is an encryption technique
that can be used along with cryptography as an extra-secure method in which to
protect data.

Steganography techniques can be applied to images, a video file or an audio file.


Typically, however, steganography is written in characters including hash marking,
but its usage within images is also common. At any rate, steganography protects from
pirating copyrighted materials as well as aiding in unauthorized viewing.

ABSTRACT
Steganography is derived from the Greek word steganos which literally means
Covered and graphy means Writing, i.e. covered writing. Steganography refers to
the science of invisible communication. For hiding secret information in various file
formats, there exists a large variety of steganographic techniques some are more
complex than others and all of them have respective strong and weak points. The
Least Significant Bit (LSB) embedding technique suggests that data can be hidden in
the least significant bits of the cover image and the human eye would be unable to
notice the hidden image in the cover file. This technique can be used for hiding
images in 24-Bit, 8-Bit, Gray scale
EXISTING SYSTEM
Image compression techniques are extensively used in steganography. Among the two
types of image compressions, lossy compression and loss less compression; lossless
compression formats offer more promises. Lossy compression compression may not

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

maintain the original images integrity. Lossless compression maintains the original
image data exactly, hence it is prefered. Example of Lossy compression format is
JPEG format files. Examples of Lossless compression formats are GIF[3] and BMP
formats.
PROPOSED SYSTEM
The Data Hiding in Audio Files mainly developed to embed or extract the
messages into audio files. This project basically deals with two important network
security concepts namely steganography and encryption. For encryption AES
algorithm is used. The plaintext is given as input. The plaintext is encrypted using
AES algorithm. The ciphertext is given as output. The output ciphertext is hidden into
the audio files using Seganography. For steganography LSB algorithm is used. The
audio file is in the wave format is the chosen medium to conceal and transmit the
secret information. Since the audio file is in ASCII format, the contents of the text file
are also converted to the bit stream. The encrypted file is now embedded behind the
audio file by mixing the contents together using LSB algorithm. At the other end, the
encrypted file is separated from audio file. The encrypted file is then decrypted and
the original text file contents are then viewed.

SYSTEM IMPLEMENTATION:
There are two types of Implementation

Implementation of a computer system to replace a manual one.

Implementation of a new computer system to replace an existing one.


LSB

Data hiding in the least significant bits (LSBs) of audio samples in the time domain is
one of the simplest algorithms with very high data rate of additional information. The
LSB watermark encoder usually selects a subset of all available host audio samples
chosen by a secret key. The substitution operation on the LSBs is performed on this
subset, where the bits to be hidden substitute the original bit values. Extraction

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

process simply retrieves the watermark by reading the value of these bits from the
audio stego object. Therefore, the decoder needs all the samples of the stego audio
that were used during the embedding process. The random selection of the samples
used for embedding introduces low power additive white Gaussian noise (AWGN). It
is well known from the psychoacoustics literature [6] that the human auditory system
(HAS) is highly sensitive to AWGN. That fact limits the number of LSB that can be
imperceptibly modified during watermark embedding. As the number of used LSBs
during LSB coding increases or, equivalently, depth of the modified LSB layer
becomes larger, perceptual transparency of stego objects is decreased. Therefore, there
is a limit for the depth of the used LSB layer in each sample of host audio that can be
used for data hiding. Subjective listening test showed that, in average, the maximum
LSB depth that can be used for LSB based watermarking without causing noticeable
perceptual distortion is the fourth LSB layer when 16 bits per sample audio sequences
are used. The tests were performed with a large collection of audio samples and
individuals with different background and musical experience. None of the tested
audio sequences had perceptual artifacts when the fourth LSB has been used for data
hiding, although in certain music styles, the limit is even higher than the fourth LSB
layer. Robustness of the watermark, embedded using the LSB coding method,
increases with increase of the LSB depth used for data hiding. Therefore,
improvement of watermark robustness obtained by increase of depth of the used LSB
layer is limited by perceptual transparency bound, which is the fourth LSB layer for
the standard LSB coding algorithm.

SYSTEM REQUIREMENTS
Hardware Specification
. Processor

Pentium IV

. RAM

256 MB

. CPU Clock

1.6 GHz

Software Specification

10

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

. Front End

JAVA

. Back End

MS-Access

. Platform

Windows XP

. Web Server

TOMCAT

TABLE DESIGN

1.

REGISTRATION

11

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

FIELD

TYPE

SIZE

NAME

VARCHAR

20

MAIL ID

VARCHAR

20

USER NAME

VARCHAR

20

PASSWORD

VARCHAR

20

CONFIRM PASSWORD

VARCHAR

20

2.

LOG IN

FIELD

TYPE

SIZE

USER NAME

VARCHAR

20

PASSWORD

VARCHAR

20

USER TYPE

VARCHAR

20

DATAFLOW DIAGROM

12

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

13

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

14

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

15

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

SYSTEM TESTING

16

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

4.SYSTEM TESTING

Testing is an activity to verify that a correct system is being built and is


performed with the intent of finding fault in the system.However not restricted to
being performed after the development phase is complete. But this is to carry out in
parallel with all stages of system development, starting with requirement
specification. Testing results, once gathered and evaluated, provide a qualitative
indication of software quality and reliability and serve as a basis for design
modification if required. A project is said to be incomplete without proper
testing.System testing can be broadly classified into:-

Unit testing.
Integration testing.
Validation testing.
Output testing.
User acceptance testing.
4.1 UNIT TESTING

In computer programming, unit testing is a procedure used to validate that individual


units of source code are working properly. A unit is the smallest testable part of an

17

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

application. In procedural programming a unit may be an individual program,


function, procedure, etc., while in object-oriented programming, the smallest unit is a
method, which may belong to a base/super class, abstract class or derived/child class.
Ideally, each test case is independent from the others; mock or fake objects as well as
test harnesses can be used to assist testing a module in isolation. Unit testing is
typically done by software developers to ensure that the code they have written meets
software requirements and behaves as the developer intended.
In this we test each module individually but not integrate the whole system. It focuses
verification efforts even in the smallest unit of software design in each module. This is
also known as Module Testing. The testing is carried out in the programming style
itself. In this testing each module is focused to work satisfactorily as regard to the
expected output from the module. There are some validation checks for the fields.
4.2 INTEGERATION TESTING
Integration testing (sometimes called Integration and Testing, abbreviated I&T) is the
phase of software testing in which individual software modules are combined and
tested as a group. It follows unit testing and precedes system testing. Integration
testing takes as its input modules that have been unit tested, groups them in larger
aggregates, applies tests defined in an integration test plan to those aggregates, and
delivers as its output the integrated system ready for system testing.
Data can be lost across an interface, one module can have adverse effect on the other
sub-functions, when combined may not produce the desired functions.

18

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

Integration testing is the systematic testing to uncover the errors within the interface.
This testing is done with simple data .The need for an integrated system is to find the
overall performance.
The purpose of integration testing is to verify functional, performance
and reliability requirements placed on major design items. These "design items", i.e.
assemblages (or groups of units), are exercised through their interfaces using black
box testing, success and error cases being simulated via appropriate parameter and
data inputs. Simulated usage of shared data areas and inter-process communication is
tested and individual subsystems are exercised through their input interface. Test
cases are constructed to test that all components within assemblages interact correctly,
for example across procedure calls or process activations, and this is done after testing
individual modules, i.e. unit testing.
4.3VALIDATION TESTING
At the culmination of black box testing (Here the structure of the program is not
considered), software is completely assembled as a package .Interface errors have
been uncovered and correct and final series of tests, i.e., and validation test begins.
The customer defines validation with a simple definition and validation succeeds
When the software functions in manner than can be reasonably accepted
4.4 OUTPUT TESTING
The output of the software should be acceptable to the system user. The output
requirement is defined during the system analysis. Testing of the software system is
done against the output and the output testing was completed with success

19

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

4.5 USER ACCEPTANCE TESTING


The system is validated by negotiating the existing and proposed system. This test
evaluates the system in the real time environment with live data and finds it to be
satisfied. This is done by the user. The various possibilities of the data are entered
and response from the system is tested once the acceptance testing is signed off by
the user.

SYSTEM IMPLEMENTATION

20

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

5.SYSTEM IMPLEMENTATION
Implementation is the stage, which is crucial in the lifecycle of new system
designed. The main stages in the implementation is,
1. Planning.
2. Testing.
3. System testing.
This system implementation phase is consists of the following steps:
Testing the developed software with sampled data correction of any error if
identified.
Creating the files of the system with actual data.
Making necessary changes to the system to find out errors.

21

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

Training of user personal data.


The system has been tested with sample data, changes are made to the
user requirements and run in parallel with existing system to find out the
discrepancies. The user has also been appraised how to run the system during
the training period. A crucial phase in the system lifecycle is successful
implementation of the new system design. Implementation simply means
converting a new system design into an operation. This involves creating
computer compatible files, training the operating staffs and installing
hardware, terminals and telecommunication network before the system up and
running. A critical factor in conversion is not disrupting the functioning of an
organization. Implementation means converting a new system or revised
system into an operational one.
It is the process if designing from an old system to the new one. Several
procedures and documents are carried during the conversion process.
There are three types of implementation,
1. Implementation of computer system to replace a manual system. The
problems encountered are converting files, training users, creating
accurate files and verifying printouts for integrity.
2. Implementation of a new computer system to replace an existing one.
This is usually a difficult conversion. If not properly planned, there can
be many problems. Some large computer systems have taken as long as a
year to convert.
3. Implementation of a modified application to replace an existing one,
using the same computer. This type of conversion is relatively easy to
handle, provided there are no major changes in the file.
The method of implementation and time scale to be
adopted is found out initially. Next the system is tested properly and at

22

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

the same time the users are trained in the new procedures. Proper
implementation is essential
organization

requirements.

to provide a reliable system to meet


Successful

implementation

may

not

guarantee improvement in the organization using the new system, but it


will prevent improper installation.
5.1 SYSTEM SECURITY
Proper security measures are done s that no external intruders enter into The site and
make securite changes.Login facility is applied to make securityTo the site.Users with
proper
username can password can only enter the site.

No navigation with the browser buttons is available in the site.It hasBeen blocked
using javascript coding.Sessions are always cleared when Logout.

23

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

SYSTEM MAINTENANCE

24

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

6 .SYSTEM MAINTENANCE
Once the software is delivered and deployed, the maintenance phase starts.
Software requires maintenance because there are some residual errors remaining in
the system that must be removed as they discovered. Maintenance involves
understanding the existing software(code and related documents) , understanding the
effect of change, making the changes, testing the new changes and retesting the old
parts that were not changed. The complexity of the maintenance part makes
maintenance the most costly activity in the life of software product. It is believed that
almost all software that is developed has residual errors, or bugs in them. These errors
need to be removed when discovered that leads to the software change. This is called
corrective maintenance.Corrective maintenance measure pairing, processing of
performance failures or making alterations because of previously ill-defined

25

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

problems. Software undergoes change frequently even without bugs because the
software must be upgraded and enhanced to include more features and provide more
services. This also requires modification of the software. The changed software
changes the environment, which in turn requires further change. This phenomenon is
called Low of Software Evaluation.
The keys to reduce the needs for maintenance are:
1. More accurately defining the users requirement during system development.
2. Preparation of system documentation in a better way.
3. Using more effective ways for designing processing logic and communicating it to
project team members.
4. Making better use of existing tools and techniques.
5. Managing the system engineering process effectively.
During the use of any large program, errors will occur and be reported
to the developer. The process that includes the diagnosis and correction of one or
more errors is called corrective maintenance.As the software is used
recommendations
for new capabilities, modifications to existing functions,and general enhancements
are received from users.

TYPES OF SOFTWARE MAINTENENCE


Corrective : Corrective maintenence of a software products become necessery
to rectify the bugs while the system in use
Adaptive:A software product might need maintenance when the customers
need the product to run on new platforms,on new operating systeme,or when
they need the product to be interfaced with new hardware or software

Perfective:A software product needs maintenance to support the new features


that users wnt it to support,to change diffrent functionalities of the system
according to the customers need ,or to enhance the perfomance of the system.

26

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

FUTURE ENHANCEMENTS

27

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

7 .FUTURE ENHANCEMENTS
Throughout all the phase changes keep cropping up and the system must be able to
adjust itself to the changing situation.The system has been developed keeping this in
mind. The system has been so good software must be able to Incorporate future
modifications and enhancement.Developed but changes in configurationleaves
minimum impact on the performance.
The application developed can be done with ease.The system has the capability
for easy integaration with other system.New modules can be added to the existing
system with less effort.With this system can add new functionalities like edition wise
news publishing and weather report of user Location

28

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

29

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

CONCLUSION

8 . CONCLUSION

The project Online Recruitment System was successfully completed within


the time span alloted. Every effort has been made to present the system in more user
friendly manner. All the activites provide a feeling like an easy walk over to the user
who is interfacing with the system.Atrial run of the system has been made and is
giving good results.

30

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

The software has been developed in JSP .All the modules are tested seperatly and put
together to form the main system.The system has been developed in an attractive
fashion.So user with minimum knowledge about the computers can operate the
system easly.

31

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

BIBLIOGRAPHY

9.BIBLIOGRRAPHY

32

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

Books
[1].ELIAS M. AWAD ,System Analysis And Design,
TataMcgrawHill,Second Edition ,Year 2000
[2].ROGER.S.PRESSMAN, Software Engineering,
TataMcgrawHill ,Fith Edition,Year 2004
[4].ANDREW.S.TANENBAUM ,System Analysis,
Prentice Hall India Publications,year 2000

33

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

APPENDIX

34

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

CODING

35

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

10.1 CODING

Coding in Online Recruitment System was done with JSP as the front end and SQL
server 2008 as backend.A professional coding standard and style is followed to
ensure the standardization of the software code.
Different naming convensions are used for the easy evolution of the code for the
future type.This makes the code for re-use and easy debugging for a third person.It
also enhances the internal style of coding.
Code is carried out under pure object oriented concept regarding class and its
management.Coding is well documented so as to future maintenance for a third party
agencies as the organization wishes.

36

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

INDEX CODE
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>StEgAnOgRaPhY</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet'
type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet'
type='text/css' />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<%
session.setAttribute("user", "");
%>
<div id="wrapper">
<div id="header-wrapper">

37

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<div id="header" class="container">


<div id="logo">
<h1><a
href="index.jsp">STEGANOGRAPHY</a></h1>
</div>
<div id="menu">
<ul>
<li class="current_page_item"><a
href="index.jsp">Homepage</a></li>
<li class="current_page_item"><a
href="Registration.jsp">Register</a></li>
<li class="current_page_item"><a
href="Login.jsp">LogIn</a></li>
<li class="current_page_item"><a
href="About.jsp">About</a></li>

</ul>
</div>
</div>
<div id="banner">
<div class="content"><img src="125.jpg" width="1000"
height="420" alt="" /></div>
</div>
</div>
<!-- end #header -->

<div id="footer-content-wrapper">

38

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<div id="footer-content">

</div>
</div>
<div id="footer">
<p>&copy; Untitled. All rights reserved. Images by Design by Vipin &
Eldhose</p>
</div>
<!-- end #footer -->
</div>
</body></html>
LOGIN CODE

<%@page import="java.util.Enumeration"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-Design by TEMPLATED
http://templated.co
Released for free under the Creative Commons Attribution License

Name

: ColoreGiallo

Description: A two-column, fixed-width design with dark color scheme.


Version

: 1.0

Released : 20121026

39

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>LoGiN</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet'
type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet'
type='text/css' />
<link href="style_2.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header-wrapper">
<div id="header" class="container">
<div id="logo">
<h1><a href="#">STEGANOGRAPHY</a></h1>
</div>
<div id="menu">
<ul>
<li class="current_page_item"><a
href="index.jsp">Homepage</a></li>
<li class="current_page_item"><a
href="Registration.jsp">Register</a></li>

40

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<li class="current_page_item"><a
href="Login.jsp">LogIn</a></li>
<li class="current_page_item"><a
href="About.jsp">About</a></li>

</ul>
</div>
</div>
<div id="banner">
<div class="content">

<%
String paraName=new String();
String paraValue=new String();
String Message="";
if(request.getParameterNames().hasMoreElements())
{
Enumeration<String> paras=request.getParameterNames();
while(paras.hasMoreElements())
{
paraName=paras.nextElement();
if(paraName.equals("msg"))
{
paraValue=request.getParameter("msg");
}
}

41

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

if(paraValue.equals("fail"))
{
Message="Login Failed. Check Your Username and Password";
}
else if(paraValue.equals("sess"))
{
Message="You Already Logged Out. Please Login to Continue";
}
else if(paraValue.equals("succ"))
{
Message="You Have registered Successfully. Please Login to Continue";
}
%>
<center>
<form action="log" method="post">

<h3>Login</h3>
<table>
<tr><font style="color: red;"><b><%=Message%></b></font></tr>
<tr><td>USER NAME</td><td><input type="text" name="user_name"
id="user_name"></input></td></tr>
<tr><td>PASSWORD</td><td><input type="password" name="pass"
id="pass"></input></td></tr>

42

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<tr><td><input type="submit" value="Login" name="Login"


id="Login"></input></td></tr>
<tr><td><a href="Registration.jsp">If Not a Registered User Sign Up As a
User Now</a> </td></tr>

</table>
</form>
</center>

</div>
</div>
</div>
<!-- end #header -->

<div id="footer-content-wrapper">
<div id="footer-content">

</div>
</div>
<div id="footer">
<p>&copy; Untitled. All rights reserved. Images by Design by Vipin &
Eldhose</p>
</div>
</div>
<!-- end #footer -->
</body>

43

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

</html>

LOGOUT CODE

<%-Document : newjsp
Created on : Sep 16, 2015, 10:48:18 AM
Author

: preloaded

44

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<body>
<% session.setAttribute("user","");
response.sendRedirect("index.jsp");
%>

<%--<%
session_start();
session_destroy();
header("location:login.jsp");
%>--%>
</body>
</html>
MAIN HOME CODE

<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

45

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<html>
<head>

<link rel="shortcut icon" href="$


{pageContext.request.contextPath}/theme/img/favicon.jpg" />
<link type="text/css" rel="stylesheet" href="$
{pageContext.request.contextPath}/theme/css/style.css" />
<link type="text/css" rel="stylesheet" href="$
{pageContext.request.contextPath}/theme/css/sunny/jquery-ui-1.8.19.custom.css" />

<script type="text/javascript" src="$


{pageContext.request.contextPath}/theme/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="$
{pageContext.request.contextPath}/theme/js/jquery-ui1.8.19.custom.min.js"></script>
<script type="text/javascript" src="$
{pageContext.request.contextPath}/theme/js/jquery.form.js"></script>
<script type="text/javascript" src="$
{pageContext.request.contextPath}/theme/js/utils.js"></script>
<script type="text/javascript">
function nextPage() {

window.location="logout.jsp";
}
</script>
<title>Steganography</title>

</head>

46

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<body>
<%
String user=(String)session.getAttribute("user");
if(user.equals(""))
response.sendRedirect("login.jsp?msg=sess");

%>

<div id="container">

<div id="tabs">

<ul>
<li><a href="#tab-encode">Encode</a></li>
<li><a href="#tab-decode">Decode</a></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li><li></li>

47

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li><li></li><li></
li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><
li></li><li></li><li></li><li></li><li></li>
<li><button onclick="nextPage()">Logout</button></li>
</ul>
<div id="tab-encode">

<form id="form-encode" action="$


{pageContext.request.contextPath}/encode" method="post" enctype="multipart/formdata" class="form">

<div id="encode-messages" class="messages"></div>

<div class="left half">

<div class="header">File to encode</div>

<div class="inner-container">

48

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<input type="radio" id="encoderadio-resource-local"name="encode-source"class="left radio" value="local"


onchange="toggleEncodeResourceSelection()">
<label for="encoderadio-resource-local"class="label"> Local resource</label>
<input type="file"
id="file-encode-local" name="file-encode-local"class="input" size="14" />
<div class="clear"></div>

<input type="radio"
id="encode-radio-resource-remote" name="encode-source" class="left radio"
value="remote"
onchange="toggleEncodeResourceSelection()">
<label for="encoderadio-resource-remote"class="label">Remote resource
</label>
<input type="text"
id="file-encode-remote" name="file-encode-remote" class="input"/>
<div class="clear"></div>

encode-password" style="margin-left: 20px;"

<label for="inputclass="label"> Password


</label>
<input
type="password"
id="input-encode-

password"
name="inputencode-password"

49

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

autocomplete="off"
class="input"/>
<div class="clear"></div>

encode-password" style="margin-left: 20px;"

<label for="inputclass="label"> Mail To:


</label>
<input
type="text"
id="mailto"
name="mailto"

autocomplete="off"
class="input"/>
<div class="clear"></div>

<label
for="input-encode-password"
style="margin-left: 20px;" class="label"> Subject:
</label>
<input
type="text"
id="subject"
name="subject"
autocomplete="off"
class="input"/>

50

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<div class="clear"></div>

<label
for="input-encode-password"
style="margin-left: 20px;" class="label"> Mail Body:
</label>
<textarea
rows="6"
cols="30"
id="body"
name="body"
autocomplete="off"
class="input"></textarea>
<div class="clear"></div>

<input
type="submit"
id="buttonencode"
value="Encode &
Mail"
class="input"
onclick="startLoadingEncode();" />

<div class="clear"></div>

51

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

</div>

</div>

<div class="right half" >

<div
class="header">Message</div>

<div class="inner-container">

<textarea
id="hiddenmessage"
name="hiddenmessage"
class="textarea"
maxlength="9999"
rows="5"
cols="37">
$
{requestScope.encodeMessage }
</textarea>
<div class="clear"></div>

</div>

52

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

</div>

<div class="clear"></div>

</form>

<div class="clear"></div>

<div id="images" class="images">

<div class="left half">

<div class="inner-containerleft">

<div
class="header">Original image</div>
<div
class="spacer"></div>
<div class="clear"></div>

<a href="$
{pageContext.request.contextPath}/image?version=original" target="_blank"

>

<img

53

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

id="imageoriginal"
src="$
{pageContext.request.contextPath}/image?version=original"
alt="original-image"
class="image right"/>
</a>

</div>

</div>

<div class="right half">

<div class="inner-containerright">

<div
class="header">Encoded image</div>
<div
class="spacer"></div>
<div class="clear"></div>

<a href="$
{pageContext.request.contextPath}/image?version=encoded"
download="C:/enctemp/encoded.jpg" target="_blank">

54

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<img
id="imageencoded"
src="$
{pageContext.request.contextPath}/image?version=encoded"
alt="encoded-image"
class="image left"/>

</a>

</div>

</div>
<div class="clear"></div>

</div>

<div id="loading-encode"
class="loading"></div>

</div>

<div id="tab-decode">

<form

55

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

id="form-decode"
action="$
{pageContext.request.contextPath}/decode"
method="post"
enctype="multipart/form-data"
class="form">

<div id="decode-messages"
class="messages"></div>

<div class="left half">

<div class="header">File to
decode</div>

<div class="inner-container">

<input
type="radio"
id="decode-radioresource-local"
name="decodesource"
class="left radio"
value="local"
onchange="toggleDecodeResourceSelection()">
<label

56

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

for="decoderadio-resource-local"
class="label">
Local resource
</label>
<input
type="file"
id="file-decodelocal"
name="filedecode-local"
class="input"
size="14"/>
<div class="clear"></div>

<input
type="radio"
id="decode-radioresource-remote"
name="decodesource"
class="left radio"
value="remote"
onchange="toggleDecodeResourceSelection()">
<label
for="decoderadio-resource-remote"

57

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

class="label">
Remote resource
</label>
<input
type="text"
id="file-decoderemote"
name="filedecode-remote"
class="input"/>
<div class="clear"></div>

<label
for="inputdecode-password"
style="marginleft: 20px;"
class="label">
Password
</label>
<input
type="password"
id="input-decodepassword"
name="inputdecode-password"
autocomplete="off"

58

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

class="input"/>
<div class="clear"></div>

<input
type="submit"
id="buttondecode"
value="Decode"
class="input"
onclick="startLoadingDecode();" />
<div class="clear"></div>

</div>

</div>

<div class="right half" >

<div
class="header">Message</div>

<div class="inner-container">

<textarea
id="decodedmessage"

59

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

rows="5"
cols="37"
readonly="readonly"
class="textarea">
$
{requestScope.decodedMessage}
</textarea>
<div class="clear"></div>

</div>

</div>

</form>

<div class="clear"></div>

<div id="loading-decode"
class="loading"></div>
</div>

</div>

</div>

60

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

</body>

</html>

ABOUT CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-Design by TEMPLATED
http://templated.co
Released for free under the Creative Commons Attribution License

Name

: ColoreGiallo

Description: A two-column, fixed-width design with dark color scheme.


Version

: 1.0

Released : 20121026

61

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>AbOuT</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet'
type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet'
type='text/css' />
<link href="style_3.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header-wrapper">
<div id="header" class="container">
<div id="logo">
<h1><a href="#">STEGANOGRAPHY</a></h1>
</div>
<div id="menu">
<ul>
<li class="current_page_item"><a
href="index.jsp">Homepage</a></li>
<li class="current_page_item"><a
href="Registration.jsp">Register</a></li>

62

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

<li class="current_page_item"><a
href="Login.jsp">LogIn</a></li>
<li class="current_page_item"><a
href="About.jsp">About</a></li>

</ul>
</div>
</div>
<div id="banner">
<div class="content"></div>
<body bgcolor="green">
<h1>STEGANOGRAPHY(Hidden Communication)</h1>
<tr>
<h4>Implementation of LSB Steganography and its Evaluation for Various File
Formats</h4>
</tr>
<p>
Steganography is derived from the Greek word steganos which literally means
Covered and graphy means Writing, i.e. covered writing. Steganography refers to the
science of invisible communication. For hiding secret information in various file
formats, there exists a large variety of steganographic techniques some are more
complex than others and all of them have respective strong and weak points. The
Least Significant Bit (LSB) embedding technique suggests that data can be hidden in
the least significant bits of the cover image and the human eye would be unable to
notice the hidden image in the cover file. This technique can be used for hiding
images in 24-Bit, 8-Bit, Gray scale
<tr><h4>EXISTING SYSTEM</h4></tr>
Image compression techniques are extensively used in steganography. Among the two
types of image compressions, lossy compression and loss less compression; lossless
compression formats offer more promises. Lossy compression compression may not

63

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

maintain the original images integrity. Lossless compression maintains the original
image data exactly, hence it is prefered. Example of Lossy compression format is
JPEG format files. Examples of Lossless compression formats are GIF and BMP
formats.
<tr><h4>PROPOSED SYSTEM</h4></tr>
The Data Hiding in Audio Files mainly developed to embed or extract the
messages into audio files. This project basically deals with two important network
security concepts namely steganography and encryption. For encryption AES
algorithm is used. The plaintext is given as input. The plaintext is encrypted using
AES algorithm. The ciphertext is given as output. The output ciphertext is hidden into
the audio files using Seganography. For steganography LSB algorithm is used. The
audio file is in the wave format is the chosen medium to conceal and transmit the
secret information. Since the audio file is in ASCII format, the contents of the text file
are also converted to the bit stream. The encrypted file is now embedded behind the
audio file by mixing the contents together using LSB algorithm. At the other end, the
encrypted file is separated from audio file. The encrypted file is then decrypted and
the original text file contents are then viewed.
<tr><h4>SYSTEM IMPLEMENTATION</h4></tr>
<tr><h4>There are two types of Implementation</h4></tr>
<tr> <h4> Implementation of a computer system to replace a manual one</h4></tr>
<tr><h4>Implementation of a new computer system to replace an existing
one.</h4></tr>
<tr><h4>LSB</h4></tr>
Data hiding in the least significant bits (LSBs) of audio samples in the time domain is
one of the simplest algorithms with very high data rate of additional information. The
LSB watermark encoder usually selects a subset of all available host audio samples
chosen by a secret key. The substitution operation on the LSBs is performed on this
subset, where the bits to be hidden substitute the original bit values. Extraction
process simply retrieves the watermark by reading the value of these bits from the
audio stego object. Therefore, the decoder needs all the samples of the stego audio
that were used during the embedding process. The random selection of the samples
used for embedding introduces low power additive white Gaussian noise (AWGN). It
is well known from the psychoacoustics literature [6] that the human auditory system
(HAS) is highly sensitive to AWGN. That fact limits the number of LSB that can be
imperceptibly modified during watermark embedding. As the number of used LSBs

64

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

during LSB coding increases or, equivalently, depth of the modified LSB layer
becomes larger, perceptual transparency of stego objects is decreased. Therefore, there
is a limit for the depth of the used LSB layer in each sample of host audio that can be
used for data hiding. Subjective listening test showed that, in average, the maximum
LSB depth that can be used for LSB based watermarking without causing noticeable
perceptual distortion is the fourth LSB layer when 16 bits per sample audio sequences
are used. The tests were performed with a large collection of audio samples and
individuals with different background and musical experience. None of the tested
audio sequences had perceptual artifacts when the fourth LSB has been used for data
hiding, although in certain music styles, the limit is even higher than the fourth LSB
layer. Robustness of the watermark, embedded using the LSB coding method,
increases with increase of the LSB depth used for data hiding. Therefore,
improvement of watermark robustness obtained by increase of depth of the used LSB
layer is limited by perceptual transparency bound, which is the fourth LSB layer for
the standard LSB coding algorithm.
</p>
</body>
</div>
</div>
<!-- end #header -->

<div id="footer-content-wrapper">
<div id="footer-content">
</div></div>
<div id="footer">
<p>&copy; Untitled. All rights reserved. Images by Design by Vipin &
Eldhose</p>
</div>
<!-- end #footer -->
</div>
</body>

65

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

</html>

SEND MATCH CODE


<%-Document : sendMailAttach
Created on : 18 Sep, 2015, 6:34:56 PM

66

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

Author

: Sebin

--%>

<%@page import="java.io.IOException"%>
<%@page import="javax.mail.internet.MimeMultipart"%>
<%@page import="javax.mail.internet.MimeBodyPart"%>
<%@page import="java.util.Date"%>
<%@page import="javax.mail.internet.InternetAddress"%>
<%@page import="javax.mail.internet.MimeMessage"%>
<%@page import="javax.mail.*"%>
<%@page import="javax.mail.Session"%>
<%@page import="javax.mail.PasswordAuthentication"%>
<%@page import="javax.mail.Authenticator"%>
<%@page import="java.util.Properties"%>
<%@page import="com.oreilly.servlet.MultipartRequest"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
MultipartRequest mr=new
MultipartRequest(request,"D:\\main_Project\\SandB\\web\\Admin\\mail");

String mail_path="mail";
mail_path=mail_path.concat("/");
mail_path=mail_path.concat(mr.getOriginalFileName("file_name"));

67

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

final String username = "sandbinfrakochin@gmail.com";


final String password = "sandb111";
String toAddress="sebinmunthiringattu@gmail.com";
String subject="Quotation From S&B Infra";
String message="Sir/Madam\nThis mail includes an attachment regarding
detailed quotation for your requirement that you have made through our website.
Pleae find the attachent. \nThanks & Regards";

Properties properties = new Properties();


properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.port", "587");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.user", username);
properties.put("mail.password", password);

// creates a new session with an authenticator


Authenticator auth = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
};
Session sess = Session.getInstance(properties, auth);

// creates a new e-mail message


Message msg = new MimeMessage(sess);

68

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

msg.setFrom(new InternetAddress(username));
InternetAddress[] toAddresses = { new InternetAddress(toAddress) };
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());

// creates message part


MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(message, "text/html");

// creates multi-part
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);

// adds attachments
if (mail_path != null ) {

MimeBodyPart attachPart = new MimeBodyPart();


try {
attachPart.attachFile(mail_path);
} catch (IOException ex) {
ex.printStackTrace();
}
multipart.addBodyPart(attachPart);

69

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

}
// sets the multi-part as e-mail's content
msg.setContent(multipart);
// sends the e-mail
Transport.send(msg);
}
}

%>

70

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

ENCODED CODE
package org.university.steganography.algorithm;
import java.awt.image.BufferedImage;
import org.university.steganography.exception.SteganographyException;
import org.university.steganography.util.Constants;
import org.university.steganography.util.Log;
import org.university.steganography.util.MessageConstants;
/**
* Class used to encode and decode messages in image objects. <b>LSB (Least
* Significant Bit)</b> algorithm is used.
*
* @author Kiril Aleksandrov
*
*/
public class Steganography
{

/**
* Encodes message into the given image
*
* @param bufferedImage

71

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

The image that will carry the encoded message


* @param message
*

The message to encoded


* @param offset

The index of the starting byte

* @return New image encoded with the message


* @throws SteganographyException
*/
public BufferedImage encode(final BufferedImage bufferedImage, final String
message, final int offset)
throws SteganographyException
{
final BufferedImage image = this.addText(bufferedImage, message,
offset);
return image;
}
/**
* Decodes and gets a hidden message (if it exists) from the given image.
* The used algorithm is <b>LSB (Least Significant Bit)</b>
*
* @param bufferedImage
*

The image to be docoded


* @param startingOffset

The index of the starting byte

* @return The message extracted from the image


* @throws SteganographyException

72

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

*/
public String decode(final BufferedImage bufferedImage, final int
startingOffset) throws SteganographyException
{
byte[] decode = null;
try
{
decode = this.decodeText(bufferedImage, startingOffset);
final String decodedMessage = new String(decode);
return decodedMessage;
}
catch (Exception e)
{
throw new
SteganographyException(MessageConstants.DECODING_ERROR_GENERAL);
}
}

/**
* Encodes text into the given image
*
* @param bufferedImage
*

The image that will carry the encoded message


* @param text
*

The text to encoded


* @param offset

73

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

The index of the starting byte

* @return New image encoded with the text


* @throws SteganographyException
*/
private BufferedImage addText(BufferedImage image, final String text, final
int offset)
throws SteganographyException
{
// Convert all items to byte arrays: image, message, message length
final byte msg[] = text.getBytes();
final byte len[] = bitConversion(msg.length);
try
{
// Encode the message length
image = this.encodeText(image, len, offset);
// Encode the message
image = this.encodeText(image, msg, offset +
Constants.HIDDEN_MESSAGE_BIT_LENGTH);
}
catch (Exception e)
{
throw new
SteganographyException(MessageConstants.ENCODING_ERROR_GENERAL, e);
}

return image;

74

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

/**
* Converts the given number to array of bytes
*
* @param i
*

The number to be converted

* @return The byte array representing the number


*/
private byte[] bitConversion(final int i)
{
final byte byte3 = (byte) ((i & 0xFF000000) >>> 24);
final byte byte2 = (byte) ((i & 0x00FF0000) >>> 16);
final byte byte1 = (byte) ((i & 0x0000FF00) >>> 8);
final byte byte0 = (byte) ((i & 0x000000FF));
return (new byte[]
{ byte3, byte2, byte1, byte0 });
}

/**
* Encodes text into the given image
*
* @param bufferedImage
*

The image that will carry the encoded message


* @param addition

75

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

The text to encoded


* @param offset

The index of the starting byte

* @return New image encoded with the text


* @throws SteganographyException
*/
private BufferedImage encodeText(final BufferedImage image, final byte[]
addition, final int offset)
throws SteganographyException
{
// Gets the image dimensions
final int height = image.getHeight();
final int width = image.getWidth();

// Initialize variables for iteration


int i = offset / height;
int j = offset % height;

Log.info("Width : " + width);


Log.info("Height : " + height);

if ((width * height) >= (addition.length * 8 + offset))


{
// Iterates over all message's bytes
for (final byte add : addition)

76

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

{
// Iterates over all of the bits in the current byte
for (int bit = 7; bit >= 0; --bit)
{
Log.info("[ " + i + " , " + j + " ]");
// Gets the original image byte value
final int imageValue = image.getRGB(i, j);

// Calculates the new image byte value


int b = (add >>> bit) & 1;
final int imageNewValue = ((imageValue &
0xFFFFFFFE) | b);

// Sets the new image byte value


image.setRGB(i, j, imageNewValue);

if (j < (height - 1))


{
++j;
}
else
{
++i;
j = 0;
}

77

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

}
}
else
{
throw new
SteganographyException(MessageConstants.ENCODING_ERROR_BIG_MESSAGE
);
}

return image;
}

/**
* Decodes and gets a hidden message (if it exists) from the given image.
* The used algorithm is <b>LSB (Least Significant Bit)</b>
*
* @param image
*

The image to be decoded


* @param startingOffset

The index of the starting byte

* @return The message extracted from the image


*/
private byte[] decodeText(final BufferedImage image, final int startingOffset)
{

78

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

// Initialize starting variables


final int height = image.getHeight();
final int offset = startingOffset +
Constants.HIDDEN_MESSAGE_BIT_LENGTH;
int length = 0;

// Loop through 32 bytes of data to determine text length


for (int i = startingOffset; i < offset; ++i)
{
final int h = i / height;
final int w = i % height;

final int imageValue = image.getRGB(h, w);


length = (length << 1) | (imageValue & 1);
}

Log.info("LENGTH : " + length);

byte[] result = new byte[length];

// Initialize variables for iteration


int i = offset / height;
int j = offset % height;

// Iterate from zero to message length

79

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

for (int letter = 0; letter < length; ++letter)


{
// Iterates over each bit for the hidden message
for (int bit = 7; bit >= 0; --bit)
{
// Gets the byte from the image
final int imageValue = image.getRGB(i, j);

// Calculates the bit for the message


result[letter] = (byte) ((result[letter] << 1) | (imageValue
& 1));

if (j < (height - 1))


{
++j;
}
else
{
++i;
j = 0;
}
}
}

return result;

80

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

DECODED CODE

81

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

package org.university.steganography.algorithm;

import java.awt.image.BufferedImage;

import org.university.steganography.exception.SteganographyException;
import org.university.steganography.util.Constants;
import org.university.steganography.util.Log;
import org.university.steganography.util.MessageConstants;

/**
* Class used to encode and decode messages in image objects. <b>LSB (Least
* Significant Bit)</b> algorithm is used.
*
* @author Kiril Aleksandrov
*
*/
public class Steganography
{

/**
* Encodes message into the given image
*
* @param bufferedImage
*

The image that will carry the encoded message

82

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

* @param message
*

The message to encoded


* @param offset

The index of the starting byte

* @return New image encoded with the message


* @throws SteganographyException
*/
public BufferedImage encode(final BufferedImage bufferedImage, final String
message, final int offset)
throws SteganographyException
{
final BufferedImage image = this.addText(bufferedImage, message,
offset);
return image;
}

/**
* Decodes and gets a hidden message (if it exists) from the given image.
* The used algorithm is <b>LSB (Least Significant Bit)</b>
*
* @param bufferedImage
*

The image to be docoded


* @param startingOffset

The index of the starting byte

* @return The message extracted from the image


* @throws SteganographyException

83

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

*/
public String decode(final BufferedImage bufferedImage, final int
startingOffset) throws SteganographyException
{
byte[] decode = null;
try
{
decode = this.decodeText(bufferedImage, startingOffset);
final String decodedMessage = new String(decode);
return decodedMessage;
}
catch (Exception e)
{
throw new
SteganographyException(MessageConstants.DECODING_ERROR_GENERAL);
}
}

/**
* Encodes text into the given image
*
* @param bufferedImage
*

The image that will carry the encoded message


* @param text
*

The text to encoded


* @param offset

84

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

The index of the starting byte

* @return New image encoded with the text


* @throws SteganographyException
*/
private BufferedImage addText(BufferedImage image, final String text, final
int offset)
throws SteganographyException
{
// Convert all items to byte arrays: image, message, message length
final byte msg[] = text.getBytes();
final byte len[] = bitConversion(msg.length);
try
{
// Encode the message length
image = this.encodeText(image, len, offset);
// Encode the message
image = this.encodeText(image, msg, offset +
Constants.HIDDEN_MESSAGE_BIT_LENGTH);
}
catch (Exception e)
{
throw new
SteganographyException(MessageConstants.ENCODING_ERROR_GENERAL, e);
}

return image;

85

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

/**
* Converts the given number to array of bytes
*
* @param i
*

The number to be converted

* @return The byte array representing the number


*/
private byte[] bitConversion(final int i)
{
final byte byte3 = (byte) ((i & 0xFF000000) >>> 24);
final byte byte2 = (byte) ((i & 0x00FF0000) >>> 16);
final byte byte1 = (byte) ((i & 0x0000FF00) >>> 8);
final byte byte0 = (byte) ((i & 0x000000FF));
return (new byte[]
{ byte3, byte2, byte1, byte0 });
}

/**
* Encodes text into the given image
*
* @param bufferedImage
*

The image that will carry the encoded message


* @param addition

86

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

The text to encoded


* @param offset

The index of the starting byte

* @return New image encoded with the text


* @throws SteganographyException
*/
private BufferedImage encodeText(final BufferedImage image, final byte[]
addition, final int offset)
throws SteganographyException
{
// Gets the image dimensions
final int height = image.getHeight();
final int width = image.getWidth();

// Initialize variables for iteration


int i = offset / height;
int j = offset % height;

Log.info("Width : " + width);


Log.info("Height : " + height);

if ((width * height) >= (addition.length * 8 + offset))


{
// Iterates over all message's bytes
for (final byte add : addition)

87

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

{
// Iterates over all of the bits in the current byte
for (int bit = 7; bit >= 0; --bit)
{
Log.info("[ " + i + " , " + j + " ]");
// Gets the original image byte value
final int imageValue = image.getRGB(i, j);

// Calculates the new image byte value


int b = (add >>> bit) & 1;
final int imageNewValue = ((imageValue &
0xFFFFFFFE) | b);

// Sets the new image byte value


image.setRGB(i, j, imageNewValue);

if (j < (height - 1))


{
++j;
}
else
{
++i;
j = 0;
}

88

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

}
}
else
{
throw new
SteganographyException(MessageConstants.ENCODING_ERROR_BIG_MESSAGE
);
}

return image;
}

/**
* Decodes and gets a hidden message (if it exists) from the given image.
* The used algorithm is <b>LSB (Least Significant Bit)</b>
*
* @param image
*

The image to be decoded


* @param startingOffset

The index of the starting byte

* @return The message extracted from the image


*/
private byte[] decodeText(final BufferedImage image, final int startingOffset)
{

89

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

// Initialize starting variables


final int height = image.getHeight();
final int offset = startingOffset +
Constants.HIDDEN_MESSAGE_BIT_LENGTH;
int length = 0;

// Loop through 32 bytes of data to determine text length


for (int i = startingOffset; i < offset; ++i)
{
final int h = i / height;
final int w = i % height;

final int imageValue = image.getRGB(h, w);


length = (length << 1) | (imageValue & 1);
}

Log.info("LENGTH : " + length);

byte[] result = new byte[length];

// Initialize variables for iteration


int i = offset / height;
int j = offset % height;

// Iterate from zero to message length

90

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

for (int letter = 0; letter < length; ++letter)


{
// Iterates over each bit for the hidden message
for (int bit = 7; bit >= 0; --bit)
{
// Gets the byte from the image
final int imageValue = image.getRGB(i, j);

// Calculates the bit for the message


result[letter] = (byte) ((result[letter] << 1) | (imageValue
& 1));

if (j < (height - 1))


{
++j;
}
else
{
++i;
j = 0;
}
}
}

return result;

91

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

92

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

SCREEN SHOT

HOME

93

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

ABOUT
LOG IN

94

STEGANOGRAPHY(Hidden Communication)
PROJECT REPORT 2015

REGISTRATION

95

You might also like