List of utility methods to do xor
byte[] | xor(byte abyte0[]) xor byte abyte1[] = null; if (abyte0 != null) { abyte1 = new byte[abyte0.length]; for (int i = 0; i < abyte0.length; i++) abyte1[i] = (byte) (0x5f ^ abyte0[i]); return abyte1; |
byte[] | xor(byte data[], byte key[]) xor final byte[] result = new byte[data.length]; int pos = 0; for (int i = 0; i < result.length; i++) { result[i] = (byte) (data[i] ^ key[pos++]); if (pos == key.length) { pos = 0; return result; |
byte[] | xor(byte lhs[], byte rhs[]) xor if ((lhs == null) || (rhs == null) || (lhs.length != rhs.length)) return null; byte diff[] = new byte[lhs.length]; xor(lhs, 0, rhs, 0, diff, 0, lhs.length); return diff; |
byte[] | xor(byte[] a, byte[] b) xor if (a.length != b.length) { throw new IllegalArgumentException("Arrays a and b should have equal length"); byte[] result = new byte[a.length]; for (int i = 0; i < a.length; i++) { result[i] = (byte) (a[i] ^ b[i]); return result; ... |
byte[] | xor(byte[] a, byte[] b) a ^ b if (a == null) throw new IllegalArgumentException("a should not be null"); if (b == null) throw new IllegalArgumentException("b should not be null"); if (a.length != b.length) throw new IllegalArgumentException("byte array length should be same"); int len = a.length; byte[] result = new byte[len]; ... |
byte[] | xor(byte[] a, byte[] b) xor if (a.length != b.length) { throw new IllegalArgumentException( "Byte arrays must have same size, was: " + a.length + " and " + b.length); byte[] out = new byte[a.length]; for (int i = 0; i < a.length; i++) { out[i] = sign(((int) a[i]) ^ ((int) b[i])); return out; |
byte[] | xor(byte[] a, byte[] b) XOR's two byte arrays. int length = Math.max(a.length, b.length); byte[] result = new byte[length]; int i = 0; for (byte val : a) { result[i] = (byte) (val ^ b[i++]); return result; |
byte[] | xor(byte[] a, byte[] b) xor byte[] dst = new byte[a.length]; xor(a, 0, b, 0, dst, 0, dst.length); return dst; |
byte[] | xor(byte[] a, byte[] b) bytewise xor of two arrays byte[] c = new byte[Math.min(a.length, b.length)]; for (int i = 0; i < c.length; i++) { c[i] = (byte) (a[i] ^ b[i]); return c; |
void | xor(byte[] a, int offsetA, byte[] b, int offsetB, byte[] dst, int dstOffset, int length) XOR length number of bytes from a with b using the syntax ( a[i] ^ b[i] ) and store the result in dst for (int i = 0, aI = offsetA, bI = offsetB, dstI = dstOffset; i < length; i++, aI++, bI++, dstI++) { dst[dstI] = (byte) (a[aI] ^ b[bI]); |