Delphi 加密工具 使用CnPack
fstream:=TMemoryStream.Create();
DestStream:=TMemoryStream.Create;
fstream.LoadFromFile(edt1.Text);
fcnstream:=TCnXorStream.Create(fstream,'123456789',false);
GetMem(buffer, fstream.Size);
fcnstream.Read(buffer^,fstream.Size);
DestStream.write(buffer^,fstream.size);
str:=StringReplace(edt1.Text,'.png','.cee',[rfReplaceAll]);
DestStream.SaveToFile(str);
ShowMessage(str);
更改代码 CCImage.cpp
if (!data.isNull())
{
//图像加密
auto bin = data.getBytes(); //unsigned char*
auto size = data.getSize();
unsigned char *buffer = (unsigned char*)malloc(sizeof(unsigned char)* (size ));
buffer = data.getBytes();
std::string r = ".cee";
const char *show;
show = strstr(_filePath.c_str(), r.c_str());//返回指向第一次出现r位置的指针,如果没找到则返回NULL。
if (show != NULL)
{
if (PASSWORD)
{
auto *cur = reinterpret_cast<char *>(bin);
int i;
//string pw = PASSWORD;
std::stringstream strValue;
strValue << PASSWORD;
char* ps = new char[50];
strValue >> ps;;
int l = strlen(ps);
for (i = 0; i < size; i++)
{
//*cur^= ps[(i % l)+1 ];
// cur++;
cur[i] ^= ps[(i % l)];
}
//for i : = 0 to Count - 1 do
//PByteArray(@Buffer) ^ [i] : = PByteArray(@Buffer) ^ [i] xor
// Byte(FXorStr[(p + i) mod l + 1]);
}
}