Java Array xor xorArrays(byte[] a, byte[] b)

Here you can find the source of xorArrays(byte[] a, byte[] b)

Description

Computes array-wise XOR.

License

Open Source License

Parameter

Parameter Description
a the first array.
b the second array.

Return

the XOR-ed array.

Declaration

public static byte[] xorArrays(byte[] a, byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w w  w .  j  a v a2 s .  c o  m
     * Computes array-wise XOR.
     * 
     * @param a
     *            the first array.
     * @param b
     *            the second array.
     * @return the XOR-ed array.
     */
    public static byte[] xorArrays(byte[] a, byte[] b) {
        byte[] xor = new byte[a.length];

        for (int i = 0; i < a.length; i++) {
            xor[i] = (byte) (a[i] ^ b[i]);
        }

        return xor;
    }
}

Related

  1. xor(byte[] left, byte[] right)
  2. XorArray(byte[] pbSource, int nSourceOffset, byte[] pbBuffer, int nBufferOffset, int nLength)
  3. xorArrayBytes(byte[] operador1, byte[] operador2)
  4. xorArrays(byte[] a, byte[] b)
  5. xorArrays(byte[] src, byte xor, byte xor_s, byte xor_e)
  6. xorBlock(byte[] a, int aOff, byte[] b, int bOff, byte[] dst, int dstOff, int len)
  7. xorByteArrays(byte[] a, byte[] b)