Here you can find the source of xor(byte[] array1, byte[] array2)
Parameter | Description |
---|---|
array1 | The first array to XOR |
array2 | The second array to XOR |
protected static byte[] xor(byte[] array1, byte[] array2)
//package com.java2s; //License from project: Open Source License public class Main { /**/* ww w . jav a 2 s .c o m*/ * XORs two byte arrays of different or same size. * @param array1 The first array to XOR * @param array2 The second array to XOR * @return The resulting byte array */ protected static byte[] xor(byte[] array1, byte[] array2) { if (array1.length > array2.length) { // make array2 the larger array byte[] tmp = array2; array2 = array1; array1 = tmp; } for (int i = 0; i < array1.length; i++) { array2[i] = (byte) (array1[i] ^ array2[i]); } return array2; } }