Here you can find the source of xor(char[] a, char[] b)
public static char[] xor(char[] a, char[] b)
//package com.java2s; /**//from ww w . j ava 2s . com * WebSYNC Client Copyright 2007, 2008 Dataview Ltd * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * A copy of the GNU General Public License version 3 is included with this * source distribution. Alternatively this licence can be viewed at * <http://www.gnu.org/licenses/> */ public class Main { /** * @return xor of arrays a and b */ public static char[] xor(char[] a, char[] b) { int length = Math.min(a.length, b.length); char[] result = new char[length]; for (int i = 0; i < length; i++) { // ^ is the xor operator // see http://mindprod.com/jgloss/xor.html result[i] = (char) (a[i] ^ b[i]); } return result; } }