I am trying to test something and I need to assume that the input is from a client using TCP and that the data is a buffer or maybe a byte array.
So this is my try:
unsigned char buf[] = { 99, 249, 117, 130, 110, 227, 171, 204, 30, 201, 225, 130, 203, 206, 74, 88, 94, 12, 223, 172, 60, 12, 173, 26, 145, 163, 112, 124, 99, 239, 188, 98, 103, 85, 163, 135, 125, 140, 186, 220, 207, 35, 185, 14, 22, 58, 36, 239, 124, 107, 29, 27, 44, 246, 165 };
So assuming that is from the client. I would like to test to process it:
xor256.Decrypt(buf, result, sizeof(buf));
But Decrypt is:
void XOR256::Decrypt(char const* in, char* result, size_t n)
So how do I fix this?
Problems:
- Cannot initialise a variable of type - const char *with an lvalue of type- unsigned char[55]
- I am confused with this. I want to get the result but this function does not return anything. But it points data to - result. So how do I get the data?
- I'm new to C++ 
int main(int argc, const char * argv[])
{
    CXOR256Stream xor256;
    char *nkey = new char[256];
    int a = 111;
    int b = 222;
    memset(nkey, 0x00, 256);
    sprintf((char*)nkey, "%.5d_XXX%.5d_XXX_%.5d", (a+10), (b+10), (a+b));
    unsigned char s[] = { 99, 249, 117, 130, 110, 227, 171, 204, 30, 201, 225, 130, 203, 206, 74, 88, 94, 12, 223, 172, 60, 12, 173, 26, 145, 163, 112, 124, 99, 239, 188, 98, 103, 85, 163, 135, 125, 140, 186, 220, 207, 35, 185, 14, 22, 58, 36, 239, 124, 107, 29, 27, 44, 246, 165 };
    const char* buf = s; // error here
    char result[50];
    xor256.Initialize(nkey, 256, 2);
    xor256.Decrypt(buf, result, sizeof(buf));
    // no error here but I'm confused on getting the data from decrypt so is this right?
    cout << result << endl;
    return 0;
}
 
     
    