Here you can find the source of xor(byte[] a, int offsetA, byte[] b, int offsetB, byte[] dst, int dstOffset, int length)
Parameter | Description |
---|---|
a | the first array |
offsetA | the offset into the a array at which to start XORing values |
b | the second array |
offsetB | the offset into the b array at which to start XORing values |
dst | the destination array to store the XORed results in |
dstOffset | the offset into the dst array at which to start storing the XORed values |
length | the number of values to read from a and b and store in dst |
public static final void xor(byte[] a, int offsetA, byte[] b, int offsetB, byte[] dst, int dstOffset, int length)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w .j av a 2 s.co m * @return a newly created array containing the XORed results of {@code a} and {@code b} * @see ArrayUtil#xor(byte[], int, byte[], int, byte[], int, int) xor() */ public static final byte[] xor(byte[] a, byte[] b) { byte[] dst = new byte[a.length]; xor(a, 0, b, 0, dst, 0, dst.length); return dst; } /** * @see ArrayUtil#xor(byte[], int, byte[], int, byte[], int, int) xor() */ public static final void xor(byte[] a, byte[] b, byte[] dst, int length) { xor(a, 0, b, 0, dst, 0, length); } /** XOR {@code length} number of bytes from {@code a} with {@code b} using the syntax ({@code a[i] ^ b[i]}) * and store the result in {@code dst} * @param a the first array * @param offsetA the offset into the {@code a} array at which to start XORing values * @param b the second array * @param offsetB the offset into the {@code b} array at which to start XORing values * @param dst the destination array to store the XORed results in * @param dstOffset the offset into the {@code dst} array at which to start storing the XORed values * @param length the number of values to read from {@code a} and {@code b} and store in {@code dst} */ public static final void xor(byte[] a, int offsetA, byte[] b, int offsetB, byte[] dst, int dstOffset, int length) { for (int i = 0, aI = offsetA, bI = offsetB, dstI = dstOffset; i < length; i++, aI++, bI++, dstI++) { dst[dstI] = (byte) (a[aI] ^ b[bI]); } } }