求助:如何用LZMA进行加密打包、文件名加密,相关函数是哪个?例如:创建压缩包、将文件添加到压缩包等方面的函数
问题详述:
前阶段我写的小工具需要用到文件打包压缩的功能,原来已有的zip源代码可以实现打包压缩,但是无法做到文件名加密等拓展功能,知道7z比我有的zip功能更强大,后来在7z的网站(
1fbK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4y4H3j5i4u0S2L8X3!0A6k6q4)9J5k6h3y4G2L8g2)9J5c8X3I4S2j5W2)9J5c8U0N6*7i4K6u0r3i4@1g2r3i4@1u0o6i4K6R3&6i4@1f1@1i4@1t1^5i4K6S2m8i4@1f1@1i4@1t1^5i4K6S2n7i4@1f1^5i4@1u0p5i4@1u0p5i4@1f1@1i4@1u0m8i4K6R3$3i4@1f1$3i4@1u0m8i4K6V1H3i4@1f1@1i4@1u0n7i4@1p5K6i4@1f1%4i4@1p5H3i4K6R3I4e0q4A6y4b7b7`.`. SDK。
解压后发现,一大堆代码,根据网上常见的代码,我知道单个文件压缩的函数。
以下是压缩单个文件的代码:
#include <stdio.h>
#include <tchar.h>
#include <Types.h>
#include <LzmaLib.h>
#pragma comment(lib, "7z lib comprile.lib")
int _tmain(int argc, _TCHAR* argv[])
{
FILE *pFile;
_tfopen_s(&pFile,_T("1.pdf"),_T("rb"));
if (pFile == NULL)
{
_ftprintf_s(stderr,_T("Error to Open the file!"));
return -1;
}
fseek(pFile,0,SEEK_END);
size_t srcLen = ftell(pFile);
rewind(pFile);
size_t destLen = srcLen*2;
unsigned char *psrcRead = new unsigned char[srcLen]; //原始文件数据
unsigned char *pDecomress = new unsigned char[srcLen]; //存放解压缩数据
unsigned char *pLzma = new unsigned char[destLen]; //存放压缩数据
fread(psrcRead,sizeof(char),srcLen,pFile);
unsigned char prop[5];
size_t sizeProp = 5;
if (SZ_OK != LzmaCompress(pLzma,&destLen,psrcRead,srcLen,prop,&sizeProp,5,(1<<24),3,0,2,32,2))
{//出错了
_ftprintf_s(stderr,_T("压缩时出错!"));
delete psrcRead;
delete pDecomress;
delete pLzma;
fclose(pFile);
return -1;
}
FILE *pCompressFile;
_tfopen_s(&pCompressFile,_T("compress.dat"),_T("wb")); //写入压缩后的数据
if (pCompressFile == NULL)
{
_ftprintf_s(stderr,_T("创建文件出错!"));
delete psrcRead;
delete pDecomress;
delete pLzma;
fclose(pFile);
return -1;
}
fwrite(pLzma,sizeof(char),destLen,pCompressFile);
fclose(pCompressFile);
FILE *pDecompressFile;
_tfopen_s(&pDecompressFile,_T("decompress.dat"),_T("wb")); //写入解压缩数据
if (pDecompressFile == NULL)
{
_ftprintf_s(stderr,_T("写入数据出错!"));
delete psrcRead;
delete pDecomress;
delete pLzma;
fclose(pFile);
return -1;
}
if (SZ_OK != LzmaUncompress(pDecomress,&srcLen,pLzma,&destLen,prop,5))
{
delete psrcRead;
delete pDecomress;
delete pLzma;
fclose(pDecompressFile);
fclose(pFile);
return -1;
}
fwrite(pDecomress,sizeof(char),srcLen,pDecompressFile);
delete psrcRead;
delete pDecomress;
delete pLzma;
fclose(pDecompressFile);
fclose(pFile);
return 0;
}
但是我想知道关于创建压缩包、文件添加到压缩包、文件名加密等方面的函数在哪里,望有相关经验的大牛指点指点!
[培训]科锐逆向工程师培训第53期2025年7月8日开班!