memxor.c 537 Bytes
Newer Older
Niels Möller's avatar
Niels Möller committed
1 2 3 4 5 6 7 8 9
/* memxor.c
 *
 * $Id$
 */

/* XOR LEN bytes starting at SRCADDR onto DESTADDR.  Result undefined
   if the source overlaps with the destination.
   Return DESTADDR. */

10
#if HAVE_CONFIG_H
11
# include "config.h"
12 13
#endif

Niels Möller's avatar
Niels Möller committed
14 15
#include "memxor.h"

16 17
uint8_t *
memxor(uint8_t *dst, const uint8_t *src, size_t n)
Niels Möller's avatar
Niels Möller committed
18 19 20 21 22 23 24
{
  size_t i;
  for (i = 0; i<n; i++)
    dst[i] ^= src[i];

  return dst;
}
25 26 27 28 29 30 31 32 33 34 35

uint8_t *
memxor3(uint8_t *dst, const uint8_t *a, const uint8_t *b, size_t n)
{
  size_t i;
  for (i = 0; i<n; i++)
    dst[i] = a[i] ^ b[i];

  return dst;
}