0

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.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jcarlos.alvarez
0

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

Edited by gerard4143: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.