Java Utililty Methods xor

List of utility methods to do xor

Description

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

Method

voidxor(byte[] aBuffer, int aOffset, int aLength, byte[] aMask, int aMaskOffset)
xor
for (int i = 0; i < aLength; i++) {
    aBuffer[aOffset + i] ^= aMask[aMaskOffset + i];
byte[]XOR(byte[] array1, byte[] array2)
XOR two byte arrays The following method is used to XOR two byte array objects
byte[] result = new byte[array1.length];
for (int i = 0; i < array1.length; i++) {
    result[i] = (byte) (array1[i] ^ array2[i]);
return result;
byte[]xor(byte[] array1, byte[] array2)
XORs two byte arrays of different or same size.
if (array1.length > array2.length) { 
    byte[] tmp = array2;
    array2 = array1;
    array1 = tmp;
for (int i = 0; i < array1.length; i++) {
    array2[i] = (byte) (array1[i] ^ array2[i]);
return array2;
byte[]xor(byte[] b1, byte[] b2)
xor
byte[] bLess = null;
byte[] bMore = null;
if (b1.length > b2.length) {
    bLess = b2;
    bMore = b1;
} else {
    bLess = b1;
    bMore = b2;
...
byte[]xor(byte[] b1, byte[] b2)
xor
int maxl = Math.max(b1.length, b2.length);
byte[] rv = new byte[maxl];
int minl = Math.min(b1.length, b2.length);
for (int i = 0; i < minl; i++)
    rv[i] = (byte) (b1[i] ^ b2[i]);
return rv;
voidxor(byte[] block, byte[] val)
xor
for (int i = 15; i >= 0; --i) {
    block[i] ^= val[i];
voidxor(byte[] block, byte[] val)
xor
for (int i = 15; i >= 0; --i) {
    block[i] ^= val[i];
voidxor(byte[] bytes, int offset, byte[] bytesToMix, int mixOffset, int len)
xor
int bytesLength = offset + len;
for (; offset < bytesLength; offset++) {
    bytes[offset] ^= bytesToMix[mixOffset++];
byte[]xor(byte[] bytes1, byte[] bytes2)
xor
byte[] bytes = new byte[bytes1.length];
for (int i = 0; i < bytes1.length; i++) {
    bytes[i] = (byte) (bytes1[i] ^ bytes2[i % bytes2.length]);
return bytes;
byte[]xor(byte[] data, byte[] xork)
Xors two byte arrays.
byte[] ret = new byte[data.length];
int block_size = xork.length;
int block_number = data.length / block_size;
int rest = data.length % block_size;
for (int i = 0; i < block_number; i++)
    for (int j = 0; j < block_size; j++)
        ret[i * block_size + j] = (byte) (data[i * block_size + j] ^ xork[j]);
for (int j = 0; j < rest; j++)
...