Here you can find the source of XOR(byte[] array1, byte[] array2)
Parameter | Description |
---|---|
array1 | A byte array |
array2 | A byte array |
public static byte[] XOR(byte[] array1, byte[] array2)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . ja va 2s. c o m * XOR two byte arrays * * The following method is used to XOR two byte array objects * * @param array1 * A byte array * @param array2 * A byte array * @return byte[] The result of array1^array2 */ public static byte[] XOR(byte[] array1, byte[] array2) { byte[] result = new byte[array1.length]; for (int i = 0; i < array1.length; i++) { result[i] = (byte) (array1[i] ^ array2[i]); } return result; } }