Here you can find the source of xor(byte[]... bytesArr)
public static byte[] xor(byte[]... bytesArr)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] xor(byte[]... bytesArr) { if (bytesArr == null) { return null; }//from www .ja v a 2 s . c o m byte[] data = null; for (int i = 0; i < bytesArr.length; i++) { byte[] bytes = bytesArr[i]; if (bytes == null) { continue; } else if (data == null) { data = new byte[bytes.length]; System.arraycopy(bytes, 0, data, 0, data.length); continue; } if (bytes.length != data.length) { throw new IllegalArgumentException("Different length of two byte arrays"); } for (int j = 0; j < data.length; j++) { data[j] ^= bytes[j]; } } return data; } public static byte[] xor(byte[] bytes, byte aByte) { if (bytes == null) { return null; } byte[] data = new byte[bytes.length]; System.arraycopy(bytes, 0, data, 0, data.length); for (int i = 0; i < data.length; i++) { data[i] ^= aByte; } return data; } }