Java Utililty Methods Array xor

List of utility methods to do Array xor

Description

The list of methods to do Array xor are organized into topic(s).

Method

byte[]xor(byte[] left, byte[] right)
xor
if (left == null || right == null)
    return null;
if (left.length > right.length) {
    byte[] swap = left;
    left = right;
    right = swap;
byte[] out = Arrays.copyOf(right, right.length);
...
voidXorArray(byte[] pbSource, int nSourceOffset, byte[] pbBuffer, int nBufferOffset, int nLength)
Xor Array
if (pbSource == null)
    throw new IllegalArgumentException("pbSource");
if (nSourceOffset < 0)
    throw new IllegalArgumentException();
if (pbBuffer == null)
    throw new IllegalArgumentException("pbBuffer");
if (nBufferOffset < 0)
    throw new IllegalArgumentException();
...
byte[]xorArrayBytes(byte[] operador1, byte[] operador2)
Permite hacer un XOR entre dos array de bytes.
if (operador1.length > operador2.length) {
    throw new IllegalArgumentException("El operador1 es de longitud mayor que el operador2");
byte[] resultado = new byte[operador1.length];
for (int cont = 0; cont < operador1.length; cont++) {
    resultado[cont] = (byte) (operador1[cont] ^ operador2[cont]);
;
...
voidxorArrays(byte[] a, byte[] b)
Performs an XOR operation of arrays elements.
for (int i = 0; i < a.length; i++) {
    a[i] ^= b[i];
byte[]xorArrays(byte[] a, byte[] b)
Computes array-wise XOR.
byte[] xor = new byte[a.length];
for (int i = 0; i < a.length; i++) {
    xor[i] = (byte) (a[i] ^ b[i]);
return xor;
bytexorArrays(byte[] src, byte xor, byte xor_s, byte xor_e)
xor ^ <0-127>
if (src == null || src.length == 0)
    return xor;
if ((xor_s & 0xFF) == 0xFF && (xor_e & 0xFF) == 0xFF)
    return xor;
else {
    int length = src.length;
    for (int i = 0; i < length; i++) {
        writeByte((src[i] & 0xFF) ^ xor, src, i);
...
voidxorBlock(byte[] a, int aOff, byte[] b, int bOff, byte[] dst, int dstOff, int len)
xor Block
for (int i = 0; i < len; ++i)
    dst[dstOff + i] = (byte) (a[aOff + i] ^ b[bOff + i]);
byte[]xorByteArrays(byte[] a, byte[] b)
xor Byte Arrays
byte[] c = new byte[a.length];
for (int i = 0; i < a.length; i++) {
    c[i] = (byte) (a[i] ^ b[i]);
return c;
byte[]xorByteArrays(byte[] first, byte[] second)
xor Byte Arrays
if (first.length != second.length) {
    System.err.println("Lengths of inputs are not equal!");
    return null;
int length = first.length;
byte[] result = new byte[length];
int i = 0;
for (byte b : first) {
...
byte[]xorBytes(byte[] data, byte[] key)
XORs a byte array against a key.
byte[] xored = new byte[data.length];
for (int ii = 0; ii < data.length; ii++) {
    xored[ii] = (byte) (data[ii] ^ key[ii % key.length]);
return xored;