Cryptography and steganography in java The following java project contains the java source code and java examples used for cryptography and steganography. This code provides use of cryptography and steganography by using DES and TripleDES and LSB algorithm( least significant bit). PROJECT Steganography and Secret Messages - Using Arrays in Java. Objective To. Arrays in Java. Figure 1 Source Code for the Steganography Program.
PermalinkJoin GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
/** |
* Copyright © 2014 Leo Xiong <hello@leoxiong.com> |
* |
* This program is free software: you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation, either version 3 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
* |
* Steganography - to conceal data within other data |
* |
* This implementation supports concealing any form of data within |
* images by utilizing the two least significant bits of each |
* RGB (no alpha) channel of each pixel in the carrier image. |
* |
* Notes: |
* TODO: encode length of payload by using a header or TLV |
* TODO: pre-calculate maximum data capacity of carrier image |
* TODO: support carrier images with a bit depth of less than 24 bits |
* TODO: variable amount of least significant bits to use for encoding |
* TODO: better cmd line arg parser |
*/ |
importjavax.imageio.ImageIO; |
importjava.awt.image.BufferedImage; |
importjava.io.*; |
publicclassSteganography { |
publicstaticvoidmain(String[] args) { |
if (args.length <2|| args.length >3) { |
System.out.println('steganography <input image> <output image> [payload file]'); |
return; |
} |
Stopwatch stopwatch =newStopwatch(); |
try { |
if (args.length 3) { |
try { |
ImageIO.write(encode(ImageIO.read(newFile(args[0])), newBitInputStream(newFile(args[2]))), 'PNG', newFile(args[1])); |
} catch (Exception e) { |
System.err.println(e.getMessage()); |
} |
} elseif (args.length 2) { |
decode(ImageIO.read(newFile(args[0])), newBitOutputStream(newFileOutputStream(args[1]))); |
} |
System.out.println(String.format('done %sms', stopwatch.getTime() /1000000)); |
} catch (IOException e) { |
System.err.println(e.getMessage()); |
} |
} |
publicstaticBufferedImageencode(BufferedImagecarrier, BitInputStreampayload) throwsException { |
for (int y =0; y < carrier.getHeight(); y++) { |
for (int x =0; x < carrier.getWidth(); x++) { |
int pixel = carrier.getRGB(x, y) &0xFFFCFCFC; |
for (int offset =16; offset >=0; offset -=8) { |
int bits = payload.readBits(2); |
if (bits -1) |
return carrier; |
pixel |= bits << offset; |
} |
carrier.setRGB(x, y, pixel); |
} |
} |
thrownewException('not enough space'); |
} |
publicstaticvoiddecode(BufferedImagecarrier, BitOutputStreampayload) throwsIOException { |
for (int y =0; y < carrier.getHeight(); y++) { |
for (int x =0; x < carrier.getWidth(); x++) { |
for (int offset =16; offset >=0; offset -=8) { |
payload.write(2, (carrier.getRGB(x, y) >> offset) &0x3); |
} |
} |
} |
payload.close(); |
} |
} |
![Image steganography using lsb algorithm source code in java Image steganography using lsb algorithm source code in java](/uploads/1/2/5/7/125708051/910175045.jpg)
Copy lines Copy permalink
Abstract
![Steganography Project In Java With Source Code Steganography Project In Java With Source Code](/uploads/1/2/5/7/125708051/667915458.jpg)
In our system Steganography involves the method of acquiring insignificant bits in the audio file. We acquire the insignificant bits in the audio header and replace them with significant bits of data
Steganography has been used on a message, the viewer would not be able to tell that the message contains a hidden message within it. The data to be concealed is compressed and hidden within another file.
The hidden message may be placed inside the white space of text messages or the dark areas of a photographic image, or within the unused portions of a audio file format. The first item needed for Steganography is called a carrier or a container. This can be a text file, graphic file or sound file which will host the message that is desired to be hidden.
Here in our system Steganography involves the method of acquiring insignificant bits in the audio file. We acquire the insignificant bits in the audio header and replace them with significant bits of data.
When performing data hiding on audio, first the data is encrypted by password based encryption using DES algorithm to generate the cipher text. Now the cipher text is kept hidden in the audio file using low bit encoding method. When extracting the data from audio first cipher text is separated from audio then the plain text is generated by decrypting the cipher text.
SOFTWARE REQUIREMENTS:-
Operating System : Windows XP
Languages : Java 1.6
HARDWARE REQUIREMENTS:-
Processor : 600 MHz or above.
RAM (SD/DDR) : 256 MB
Hard Disc : 30GB