xoring speed

Programming related discussions related to game research
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

xoring speed

Post by chrrox »

what is the fastest way to implement this in quickbms.
void DLL_EXPORT do_decrypt(char* data_r,int len_r,int seek)
{
char* data = &data_r[seek];
int len = len_r - seek;

for(int i=0;i<len;i++)
{
char simu = data[i];
char toXo = key[i%0x180];

if(simu!=0&&simu!=toXo)
data[i] = simu^toXo;
}
}

mainly the
if(simu!=0&&simu!=toXo)
data[i] = simu^toXo;
part
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: xoring speed

Post by aluigi »

It's a conditional xor, better to use the function as-is:

Code: Select all

set MEMORY_FILE10 string "
void do_decrypt(char *key, char* data,int len)
{
    for(int i=0;i<len;i++)
    {
        char simu = data[i];
        char toXo = key[i%0x180];

        if(simu!=0&&simu!=toXo)
            data[i] = simu^toXo;
    }
}
"

set KEY binary "..."
encryption calldll "MEMORY_FILE10 do_decrypt tcc RET KEY #INPUT# #INPUT_SIZE#"

log "dump.dat" OFFSET SIZE