Java Utililty Methods Array xor

List of utility methods to do Array xor

Description

The list of methods to do Array xor are organized into topic(s).

Method

voidxorData(final byte[] data, final byte[] passBytes)
xor Data
int dlength = data.length;
if (dlength > 1 && dlength < 8193) {
    int len = passBytes.length;
    for (int i = 0; i < dlength; i++) {
        data[i] ^= passBytes[i % len];
byte[]xorDecode(byte[] str, char[] key)
xor Decode
byte[] buf = new byte[str.length];
for (int i = 0, j = 0; j < str.length; j++) {
    if (i >= 8)
        i = 0;
    buf[j] = (byte) ((char) str[j] ^ (char) key[i]);
    i++;
return buf;
...
byte[]xorend(byte[] in1, byte[] in2)
xorend
if (in1 == null || in2 == null || in1.length < in2.length) {
    throw new IllegalArgumentException("Length of first input must be >= length of second input.");
final byte[] result = Arrays.copyOf(in1, in1.length);
final int diff = in1.length - in2.length;
for (int i = 0; i < in2.length; i++) {
    result[i + diff] = (byte) (result[i + diff] ^ in2[i]);
return result;
long[]xorI(long[] v, long[] o)
XOR o onto v inplace, i.e.
assert (o.length <= v.length) : "Bit set sizes do not agree.";
for (int i = 0; i < o.length; i++) {
    v[i] ^= o[i];
return v;
byte[]xorTwoByteArrays(byte[] byteArray1, byte[] byteArray2)
xor Two Byte Arrays
int maxLength = byteArray1.length > byteArray2.length ? byteArray1.length : byteArray2.length;
int minLength = byteArray1.length > byteArray2.length ? byteArray2.length : byteArray1.length;
byte[] xorBytes = new byte[maxLength];
for (int i = 0; i < minLength; i++) {
    xorBytes[i] = (byte) (byteArray1[i] ^ byteArray2[i]);
if (maxLength == byteArray1.length)
    System.arraycopy(byteArray1, minLength, xorBytes, minLength, maxLength - minLength);
...