Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Separate merged binary files

 
ravi D shankar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

Can anyone please guide in separating 2 binary files using java api which got merged into 1 file.(appended one after the other). The file content is encoded in charset iso-8859-1.
Is there any standard way to separate individual binary files which were merged into one?

Thanks in advance,
Ravi
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just reading the contents, and writing to one FileOutputStream first, then close it and write to another FileOutputStream next. The problem will be in finding where to split.
 
ravi D shankar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you give me some info on how I can identify where to split a merged binary file using java api?

Thanks in advance,
Ravi
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well no, to be honest I can't. Like I said, that's the hard part.

What may also be important is to know what the file types should be; do you know? It may help in recognizing the headers inside the files.
 
Wentao Liang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know that too.
 
ravi D shankar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

The filetype I have is conventionally encrypted PGP/GnuPG file.
2 encrypted files have been merged into 1.
If the file format were to be ASCII, it would have been easy to separate them.
We are facing difficulties with the binary file.

Thanks
Ravi
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, let's just put Java aside for a moment.

Is this one particular file you're trying to recover the data from? And do you have the encryption key for the first file of the two? If so, here's what you do:

1) Run gpg to decrypt the combined file, supplying the key as needed. That will give you the first decrypted file. You'll get a warning about tampering because of the extra data but it will work.

2) Encrypt the first file using gpg again using the same key. Note the size of the file in bytes. That tells you the offset of the second file within the combined file!

3) Read the combined file in a Java program, skip that number of bytes from the beginning, and then write the rest to another file.

4) Decrypt that second file, if desired.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic