Here you can find the source of xor(byte[] a, byte[] b)
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
public static byte[] xor(byte[] a, byte[] b)
//package com.java2s; /**// w ww .j a v a2s .c o m * ?????????? unsigned ???????????????????????????????????????? * * License : MIT License */ public class Main { /** * a ^ b * @param a * @param b * @return */ public static byte[] xor(byte[] a, byte[] 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]; for (int i = 0; i < len; i++) { result[i] = (byte) ((a[i] ^ b[i]) & 0x000000ff); } return result; } }