Java Array Sum sum(byte[] in, byte[] gamma)

Here you can find the source of sum(byte[] in, byte[] gamma)

Description

componentwise addition modulo 2 (XOR)

License

Open Source License

Parameter

Parameter Description
in clear text
gamma gamma parameter

Declaration

public static byte[] sum(byte[] in, byte[] gamma) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*w  w w.  j  a v  a2 s. c o m*/
     * componentwise addition modulo 2 (XOR)
     *
     * @param in    clear text
     * @param gamma gamma parameter
     * @return
     */
    public static byte[] sum(byte[] in, byte[] gamma) {

        byte[] out = new byte[in.length];
        for (int i = 0; i < in.length; i++) {
            out[i] = (byte) (in[i] ^ gamma[i]);
        }
        return out;
    }
}

Related

  1. sum(byte... bytes)
  2. sum(byte[] array)
  3. sum(byte[] array)
  4. sum(byte[] array, int offset, int size)
  5. sum(byte[] array, int offset, int size)
  6. sum(double a[], int begin, int end)
  7. sum(double values[], int size)
  8. sum(double... a)
  9. sum(double... values)