Hi, I have 2 hexa arrays of 8 bytes and need to do an xor of them, something like this:

unsigned char xorBufferTemp[8];
unsigned char bufferHexas1[8];
unsigned char bufferHexas2[8];

I'd like to make something like that ...

for (i=0; i<8> i++) {
  xorBufferTemp[i] = bufferHexas1[i] ^ bufferHexas2[i];
}

But obviously it doesn't compile because the ^ work only with ones and ceros.

Any ideas would be great appreciated.
Thanks, Juan.

Recommended Answers

All 2 Replies

Just curious to what you think an unsigned char is but zeros and ones

try compiling this

#include <stdio.h>
#include <stdlib.h>

unsigned char xorBufferTemp[8];
unsigned char bufferHexas1[8];
unsigned char bufferHexas2[8];

int main(int argc, char**argv)
{
	bufferHexas1[0] = 15;
	bufferHexas2[0] = 1;
	xorBufferTemp[0] = bufferHexas1[0] ^ bufferHexas2[0];

	fprintf(stdout, "ans->%u\n", xorBufferTemp[0]);

	exit(EXIT_SUCCESS);
}

You was right, i had worked with pointers to array of unsigned chars.

Thanks Juan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.