Loop issue
can someone tell me whats wrong with my loop and why its not using the decoded key to xor the remaning buffer...
this here..
should turn into this...
Code:
void CCrypt::EnCrypt( unsigned char* buffer, unsigned size )
{
// check data correctness
if ( !buffer )
return;
if ( size < 4 )
return;
unsigned char * encBuffer = new unsigned char[ size + 4 ];
unsigned m = size + 4;
// copy data from the encBuffer to Buffer
memcpy( encBuffer, buffer + 4, sizeof( unsigned char ) * m );
const char unknown_key[] = "qmfaktnpgjs";
unsigned char unknown_key2[sizeof(unknown_key)];
std::copy(unknown_key, unknown_key + sizeof(unknown_key), unknown_key2);
if ( encBuffer == NULL)
return;
if ( m < 4 )
return;
// perform header encrypting
encBuffer[ 0 ] = m & 0xFF;
encBuffer[ 1 ] = ( m & 0xFF00 ) >> 8;
encBuffer[ 2 ] = 0x01;
encBuffer[ 3 ] = 0x00;
for (unsigned i = 4; i < m; i++)
{
if ( encBuffer[i] != 0)
{
encBuffer[ i ] = unknown_key2[i % 0xB] ^ encBuffer[ i ];
}
}
// swap buffers
delete [] buffer;
buffer = encBuffer;
size = m;
}
Code:
01 c2 eb 0b 00 11 08 01 00 00 00 00 00 01 00 46 61 63 65 6f 66 44 65 76 69 6c 00 00 00 00 00 00 00 00 00 00 00 00 00
Code:
2b 00 01 00 70 af 8d 6a 00 65 66 71 00 00 00 00 00 67 00 2d 15 0d 15 08 0c 37 14 1b 0f 0d 00 00 00 00 00 00 00 00 00 00 00 00 00