Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Encrypt & Compress multiple files

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19458 |

    I sent a similar email to Xceed support a week or two ago, but hadn’t heard back from anyone yet. What I’m trying to do is put multiple files into a single encrypted & compressed output stream, but am unable to pull the data apart when it is complete.

    So for example, I am compressing FILE1.TXT and FILE2.TXT into a single encrypted & compressed output file called FILEARCHIVE.ENC
    1] I read all bytes (in 32k chunks) of File1.txt
    2] With each chunk I write the buffer into the compression stream which
    3] Writes the compressed data to the encryption stream which
    4] writes the encrypted/compressed data to the Output Filestream (FILEARCHIVE.ENC)
    5] I read all bytes (in 32k chunks) of File2.txt
    6] With each chunk I write the buffer into the compression stream which
    7] Writes the compressed data to the encryption stream which
    8] writes the encrypted/compressed data to the Output Filestream (FILEARCHIVE.ENC)

    When I am finished, FILEARCHIVE.ENC contains the compressed and encrypted data of both files. My problem is the extraction. Since I have to READ from the compressed stream to decompress, I tried to reverse the above chaining the inputfile to the encryption stream to the compressed stream and then used the compressedstream.read to get at the data.

    The problem is, when you’re reading from the compressed stream, you are actually pulling data out based on the uncompressed filesize. This isn’t an issue since I know: The starting position of each file inside the FILEARCHIVE.ENC, the compressed size of each file in the FILEARCHIVE.ENC, as well as the uncompressed size of those files.

    So when I do a compressedstream.READ its reading from the encrypted stream which is reading from the sourcefile (FILEARCHIVE.ENC). What I believe is happening, is that because there are two files in the same filestream, that even though I’m limiting my read to the total uncompressed byte size of FILE1.txt, that it is actually starting to get data from FILE2.txt. If I were able to WRITE to the compressedstream and have it decompress, this would be easy because I’d read the exact bytes from the encrypted stream and write those to the compressed stream.

    What actually happens is that it reads the first 32k of compressed data, decompresses and removes encryption just fine. The next chunk should be less than 32k (because the total compressed size is 40+k). When it gets to this point, I get an error from the Xceed compressed stream object “An unexpected internal failure occurred in the compression engine.”. I think this is misleading because I believe its because the compressed stream hasn’t read the exact number of remaining bytes from the encrypted stream which is causing the error. As I said, the first 32k of compressed encrypted data comes out perfectly to around 300k of uncompressed original file before the error occurs.

    Does anyone have any ideas as to how this can be done? I’m pulling my hair out on this one especially since a write to the decompression would work perfectly, but isn’t possible with the Streaming Compression object.

    BTW – I did send sample code with my email to Xceed support a week or two ago.

    Imported from legacy forums. Posted by Chris (had 2928 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Chris,

    Indeed, your email did not reach us, we apologize for the delay of response I will make sure that someone from the support team gets back to you as soon as possible.

    Imported from legacy forums. Posted by Matt (had 226 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Matt! I know that sometimes email systems bounce emails with certain attachments, which likely happened with my email. I’ve noticed that the Xceed support team is very good at responding to forum posts which was why I posted yesterday. 🙂

    Imported from legacy forums. Posted by Chris (had 3981 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.