11.07.2015 Views

Java Art Chapter 6. Steganography

Java Art Chapter 6. Steganography

Java Art Chapter 6. Steganography

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Java</strong> Prog. Techniques for Games. <strong>Java</strong> <strong>Art</strong> <strong>Chapter</strong> <strong>6.</strong> Stego Draft #1 (7th June 09)System.arraycopy(lenBs, 0, stego,destPos, lenBs.length); // length of messagedestPos += lenBs.length;System.arraycopy(encryptedMsgBytes, 0, stego,destPos, encryptedMsgBytes.length); //messagereturn stego;} // end of buildStego()Whereas the old singleHide() called hideStego() once to add the message to theimage, multipleHide() calls hideStego() inside a loop. Each hideStego() call inserts acomplete copy of the message, and so usually the very end of the image is leftunmodified because there's not enough space left to add a complete message.private static boolean multipleHide(byte[] imBytes, byte[] stego){int imLen = imBytes.length;System.out.println("Byte length of image: " + imLen);int totalLen = stego.length;System.out.println("Total byte length of message: " + totalLen);// check that the stego will fit into the image/* multiply stego length by number of image bytes requiredto store one stego byte */if ((totalLen*DATA_SIZE) > imLen) {System.out.println("Image not big enough for message");return false;}// calculate the number of times the stego can be hiddenint numHides = imLen/(totalLen*DATA_SIZE); // integer divSystem.out.println("No. of message duplications: " + numHides);for(int i=0; i < numHides; i++) // hide stego numHides timeshideStego(imBytes, stego, (i*totalLen*DATA_SIZE));return true;} // end of multipleHide()4.2. Revealing the MessageThe payoff of multiple hides is that reveal() needn't just give up if a stego messagehas been corrupted, it can keep searching for another copy in the image.public static boolean reveal(String imFnm){// get the image's data as a byte arrayBufferedImage im = loadImage(imFnm);if (im == null)return false;byte[] imBytes = accessBytes(im);int imLen = imBytes.length;System.out.println("Byte Length of image: " + imLen);int headOffset = STEGO_HEADER.length()*DATA_SIZE;// stego header space used in image20 Andrew Davison © 2009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!