简体   繁体   中英

Unzipping an encrypted File in bytes

My zipped file is encrypted and i need to decrypt and unzip the File.

I am not decrypting the Full File at a time and storing in disk and unzipping as its not the optimal way of unzipping the encrypting file.

I am decrypting some bytes and want to unzip only the byte of data (memory buffer) i received from the decryptor and unzip them.

using minizip we cant unzip the buffer data from memory.can i use Zlib Inflate() ? will that work in this case?

please reply if there is any other way in doing it using minizip.

If you are talking about unzipping a zip file from a buffer stored in memory that contains the contents of the zip file then it certainly is something you can do with minizip. If you take a look at minizip it has an IO API for loading zip files from memory in order that you may unzip them.

zlib_filefunc_def FileFunctions32 = {0};
ourmemory_t *FileMemory = {0};

// Fill out ourmemory_t instance with buffer pointer (base) and length (size)

fill_memory_filefunc(&FileFunctions32, FileMemory);
UnzipFileHandle = unzOpen2("__notused__", &FileFunctions32);

There are multiple ways you can handle the encryption/decryption aspect of it. If the encryption routine is part of the zip specification, then find a library that can handle it out of the box. If the encryption is done on the entire zip file buffer then you can simply decrypt the buffer in place before you pass it to minizip's unzOpen2 function. Another option might be writing your own encryption/decryption IO API layer for minizip if none of the above scenarios is what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM