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)destPos += STEGO_HEADER.length(); // fragment numberSystem.arraycopy(fragNumBs, 0, sFrag, destPos, fragNumBs.length);destPos += fragNumBs.length;// passwordSystem.arraycopy(passBytes, 0, sFrag, destPos,passBytes.length);destPos += passBytes.length;System.arraycopy(lenBs, 0, sFrag, destPos, lenBs.length);// length of encrypted binary messagedestPos += lenBs.length;System.arraycopy(encryptedFrag, 0, sFrag, destPos,encryptedFrag.length); // encrypted binary messagereturn sFrag;} // end of buildStegoFrag()5.3. Hiding FragmentsmultipleHide() is more complicated than previously since it has to store stegofragments multiple times inside the image.The trickiest aspect of multiple insertion is deciding how many times each fragmentshould be inserted (the numHides value in the code). I went for an easy solution bydividing the total size of all the fragments into the size of the image to get numHides.private static boolean multipleHide(byte[] imBytes,byte[][] stegoFrags)// store the stego fragments multiple times in the image{int imLen = imBytes.length;System.out.println("Byte length of image: " + imLen);// calculate total length of all the stego fragmentsint totalLen = 0;for(int i=0; i < NUM_FRAGS; i++)totalLen += stegoFrags[i].length;System.out.println("Total byte length of info: " + 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 number of times the complete stego can be hiddenint numHides = imLen/(totalLen*DATA_SIZE); // integer divSystem.out.println("No. of message duplications: " + numHides);int offset = 0;for(int h=0; h < numHides; h++) //hide all frags, numHides timesfor(int i=0; i < NUM_FRAGS; i++) {hideStegoFrag(imBytes, stegoFrags[i], offset);offset += stegoFrags[i].length*DATA_SIZE;}26 Andrew Davison © 2009

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

Saved successfully!

Ooh no, something went wrong!