Here you can find the source of xor(byte[] data, byte[] xork)
Parameter | Description |
---|---|
data | First array. |
xork | Second array |
public static byte[] xor(byte[] data, byte[] xork)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w .ja v a 2s . c o m*/ * Xors two byte arrays. * * @param data First array. * @param xork Second array * @return Result of xoring the two arrays. */ public static byte[] xor(byte[] data, byte[] xork) { byte[] ret = new byte[data.length]; int block_size = xork.length; int block_number = data.length / block_size; int rest = data.length % block_size; for (int i = 0; i < block_number; i++) for (int j = 0; j < block_size; j++) ret[i * block_size + j] = (byte) (data[i * block_size + j] ^ xork[j]); for (int j = 0; j < rest; j++) ret[block_number * block_size + j] = (byte) (data[block_number * block_size + j] ^ xork[j]); return ret; } }