简体   繁体   English

解压缩以字节为单位的加密文件

[英]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() ? 使用minizip我们不能从内存中解压缩缓冲区数据。我可以使用Zlib Inflate()吗? will that work in this case? 在这种情况下可以工作吗?

please reply if there is any other way in doing it using minizip. 如果使用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. 如果您要谈论的是从存储在包含zip文件内容的内存中的缓冲区中解压缩zip文件,那么使用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. 如果您看一下minizip,它有一个IO API,用于从内存中加载zip文件,以便您可以解压缩它们。

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. 如果加密例程是zip规范的一部分,请立即找到一个可以对其进行处理的库。 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. 如果加密是在整个zip文件缓冲区中完成的,则可以在将缓冲区传递给minizip的unzOpen2函数之前简单地对其解密。 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. 如果您找不到上述方案,则另一个选择可能是为minizip编写您自己的加密/解密IO API层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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