Java Array xor xorByteArrays(byte[] first, byte[] second)

Here you can find the source of xorByteArrays(byte[] first, byte[] second)

Description

xor Byte Arrays

License

Open Source License

Declaration

public static byte[] xorByteArrays(byte[] first, byte[] second) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] xorByteArrays(byte[] first, byte[] second) {
        if (first.length != second.length) {
            System.err.println("Lengths of inputs are not equal!");
            return null;
        }/*from w  w w.  j a va2s . co  m*/
        int length = first.length;
        byte[] result = new byte[length];
        int i = 0;
        for (byte b : first) {
            result[i] = (byte) (b ^ second[i]);
            i++;
        }
        return result;
    }
}

Related

  1. xorArrays(byte[] a, byte[] b)
  2. xorArrays(byte[] a, byte[] b)
  3. xorArrays(byte[] src, byte xor, byte xor_s, byte xor_e)
  4. xorBlock(byte[] a, int aOff, byte[] b, int bOff, byte[] dst, int dstOff, int len)
  5. xorByteArrays(byte[] a, byte[] b)
  6. xorBytes(byte[] data, byte[] key)
  7. xorData(final byte[] data, final byte[] passBytes)
  8. xorDecode(byte[] str, char[] key)
  9. xorend(byte[] in1, byte[] in2)