cocos2dx 3.5 资源文件加密

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]);




}


}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值