Here you can find the source of xor(byte[]... arrays)
public static byte[] xor(byte[]... arrays)
//package com.java2s; import java.util.Arrays; import java.util.Comparator; public class Main { /**//from ww w. j a v a 2 s .c om * XORs the bits in an arbitary number of byte arrays. * * @return The result of XORing the bits in the byte arrays. */ public static byte[] xor(byte[]... arrays) { if (arrays.length == 0) return null; sortDecendingSize(arrays); byte[] result = new byte[arrays[0].length]; for (byte[] array : arrays) { for (int i = 0; i < array.length; i++) { result[i] ^= array[i]; } } return result; } public static void sortDecendingSize(byte[]... arrays) { Arrays.sort(arrays, new Comparator<byte[]>() { @Override public int compare(byte[] lhs, byte[] rhs) { if (lhs.length > rhs.length) return -1; if (lhs.length < rhs.length) return 1; else return 0; } }); } }