Here you can find the source of xor(byte[] a, byte[] b)
Parameter | Description |
---|---|
a | the first array of bytes. |
b | the second array of bytes. |
public static byte[] xor(byte[] a, byte[] b)
//package com.java2s; //License from project: Open Source License public class Main { /**// w ww . j a v a 2 s .c o m * XOR's two byte arrays. * * @param a the first array of bytes. * @param b the second array of bytes. * @return an array of bytes after being XORed. */ public static byte[] xor(byte[] a, byte[] b) { 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; } }