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?
Asked
Active
Viewed 113 times
0
-
You can't. You've destroyed the information because you cannot know where to split it. – SLaks Jun 20 '13 at 20:14
-
sure you cam by parsing the jpg file structure, but not easy. and not the recommended way. – AlexWien Jun 20 '13 at 20:28
1 Answers
0
- Open the combined file as binary in Java
- Scan for the byte sequence 0x52 0x61 0x72 0x21 0x1A 0x07 0x00
- If you find only one occurrence, that is the start of the RAR file (as in, starting with the 0x52 byte.
- 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