[Solved]Steganography Technique Hiding Secret Messages Information Within Non Secret Data Informat Q37091488
Steganography is the technique of hiding secretmessages/information within other non-secret
data/information. One popular way of steganography is hiding text(plaintext) within images (cover
text). Each image is a collection of pixels, where each pixel istypically represented by 3 values
(RGB). Each of R, G, and B is a value between 0 and 255 and thuscan be represented by 8 bits. The
color of the pixel depends on these values. However, if the leastsignificant bit (last bit from the
right) is changed for each of R, G, B then the resulting change inpixel color may not be noticeable.
Using this fact, we can convert a text message to bits and embedthem one by one in R, G, B values of
the pixel. That is, each R, G, B value’s last bit actually carriesone bit of the secret message. This is
one way to create a covert (secret) channel to pass information.Upon receipt of the image, the
receiver can extract the last bit from each R, G, B and combinethem to reveal the secret message.
In this assignment, we will follow this simple version of LSBalgorithm. The students are required to
write a Java program that can embed and extract a simple textmessage into a chosen PNG image.
The program should also allow extraction of the message from thestegotext image. In particular,
the program should do the following:
1. Prompts user to enter a choice of PNG image to hide a textmessage.
2. Prompts user to enter the text message that is to behidden.
3. Create a modified image after hiding the text message (asexplained above) and save the
image as a new PNG picture.
4. Display the hidden message when a PNG image is supplied. [Fortesting purpose, the user may
choose to use a different image file that already has a messagehidden into it following the
above scheme.]
[Hint: a sample Java code (PixelData.java) is provided on BlazeVIEWto give an idea how to get R, G, B
values of a pixel in a PNG image. You can build on that, but youneed to explore BufferedImage class,
Color class, ImageIO package in JavaFX, getRGB(), setRGB() methodsetc.from Java API.]
Here is the helper code which can help to complete theprogram
import java.util.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
public class PixelBits {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print(“Enter the input image file name (with .pngextension): “);
String file = input.next();
BufferedImage img;
try {
img = ImageIO.read(new File(file));
// There is a method ImageIO.write() to create a
// picture file from a BufferedImage object
int h = img.getHeight();
int w = img.getWidth();
int totalpixel = h*w;
System.out.println(“n Image height = ” + h + ” and Image width = “+ w);
System.out.println(” Total number of pixels = ” +totalpixel);
System.out.println(“n In each pixel you have 3 components,R-G-B.n Hence you can embed 3 bits in each pixel.”);
System.out.println(“n Total number of bits that can be embedded inthe picture = ” + totalpixel*3);
System.out.println(“n Total number of ASCII characters that can beembedded = ” + (totalpixel*3)/8);
// store each pixel’s RGB values
int[][] pixelData = new int[h*w][3];
int[] rgb;
int numberOfPixels = 0;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
rgb = PixelData(img, j, i);
for(int k = 0; k < rgb.length; k++){
pixelData[numberOfPixels][k] = rgb[k];
}
numberOfPixels++;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static int[] PixelData(BufferedImage img, int x, int y){
int argb = img.getRGB(x, y);
int[] rgb = new int[3];
rgb[0] = (argb >> 16) & 0xff; //Red
rgb[1] = (argb >> 8) & 0xff; // Green
rgb[2] = (argb) & 0xff; // Blue
// 0xff is Hex for 255 and used as a mask to get last 8 bits of abit string
// Remove the comment from the next line if you want to display RGBvalues for all pixels.
// Caution: There can be too many pixels to display. So use it ifabsolutely necessary.
//System.out.println(“Red: ” + rgb[0] + “, Green: ” + rgb[1] + “,Blue: ” + rgb[2]);
return rgb;
}
}
Expert Answer
Answer to Steganography is the technique of hiding secret messages/information within other non-secret data/information. One popul… . . .
OR

