Java Array xor xorBytes(byte[] data, byte[] key)

Here you can find the source of xorBytes(byte[] data, byte[] key)

Description

XORs a byte array against a key.

License

Open Source License

Declaration

public static byte[] xorBytes(byte[] data, byte[] key) 

Method Source Code

//package com.java2s;
// under the terms of the GNU Lesser General Public License as published

public class Main {
    /**// w w w .j  a va  2  s.  c  om
     * XORs a byte array against a key.
     */
    public static byte[] xorBytes(byte[] data, byte[] key) {
        byte[] xored = new byte[data.length];
        for (int ii = 0; ii < data.length; ii++) {
            xored[ii] = (byte) (data[ii] ^ key[ii % key.length]);
        }
        return xored;
    }
}

Related

  1. xorArrays(byte[] a, byte[] b)
  2. xorArrays(byte[] src, byte xor, byte xor_s, byte xor_e)
  3. xorBlock(byte[] a, int aOff, byte[] b, int bOff, byte[] dst, int dstOff, int len)
  4. xorByteArrays(byte[] a, byte[] b)
  5. xorByteArrays(byte[] first, byte[] second)
  6. xorData(final byte[] data, final byte[] passBytes)
  7. xorDecode(byte[] str, char[] key)
  8. xorend(byte[] in1, byte[] in2)
  9. xorI(long[] v, long[] o)