Java Array xor XorArray(byte[] pbSource, int nSourceOffset, byte[] pbBuffer, int nBufferOffset, int nLength)

Here you can find the source of XorArray(byte[] pbSource, int nSourceOffset, byte[] pbBuffer, int nBufferOffset, int nLength)

Description

Xor Array

License

Open Source License

Declaration

public static void XorArray(byte[] pbSource, int nSourceOffset, byte[] pbBuffer, int nBufferOffset,
            int nLength) 

Method Source Code

//package com.java2s;
/*/*from  w w w . j av a2s  .  c  om*/
  KeePass Password Safe - The Open-Source Password Manager
  Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
    
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
    
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
    
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

public class Main {
    public static void XorArray(byte[] pbSource, int nSourceOffset, byte[] pbBuffer, int nBufferOffset,
            int nLength) {
        if (pbSource == null)
            throw new IllegalArgumentException("pbSource");
        if (nSourceOffset < 0)
            throw new IllegalArgumentException();
        if (pbBuffer == null)
            throw new IllegalArgumentException("pbBuffer");
        if (nBufferOffset < 0)
            throw new IllegalArgumentException();
        if (nLength < 0)
            throw new IllegalArgumentException();
        if ((nSourceOffset + nLength) > pbSource.length)
            throw new IllegalArgumentException();
        if ((nBufferOffset + nLength) > pbBuffer.length)
            throw new IllegalArgumentException();

        for (int i = 0; i < nLength; ++i)
            pbBuffer[nBufferOffset + i] ^= pbSource[nSourceOffset + i];
    }
}

Related

  1. xor(byte[] left, byte[] right)
  2. xorArrayBytes(byte[] operador1, byte[] operador2)
  3. xorArrays(byte[] a, byte[] b)
  4. xorArrays(byte[] a, byte[] b)
  5. xorArrays(byte[] src, byte xor, byte xor_s, byte xor_e)