0

Please have a look into this question https://stackoverflow.com/questions/14586267/i-want-to-hide-a-document-file-behind-an-image-using-java-code?answertab=active#tab-top Now I want to know how to retrieve those combined files separately using Java?

Cœur
  • 37,241
  • 25
  • 195
  • 267
nirock
  • 1

1 Answers1

0
  1. Open the combined file as binary in Java
  2. Scan for the byte sequence 0x52 0x61 0x72 0x21 0x1A 0x07 0x00
  3. If you find only one occurrence, that is the start of the RAR file (as in, starting with the 0x52 byte.
  4. If you find multiple occurrences, you may need to use the JPEG header to guess which one is the actual RAR start.

I am not as familiar with the JPEG header, but you may be able to use the header or the segments to determine the correct RAR start. Optionally, you can modify your hiding scheme to make it easier for the intended recipient to determine the correct RAR start. One possible way is to encode the number of bytes in the image using 4 bytes, and append that to the end of the JPEG. Then append the RAR. If you find multiple matching RAR byte sequences (0x52 0x61...), the correct one is the one that is preceded by a 4 byte encoding of the number of bytes up to that point (-4 of course.)

K Boden
  • 626
  • 4
  • 6