Here you can find the source of xorArrays(byte[] src, byte xor, byte xor_s, byte xor_e)
Parameter | Description |
---|---|
src | a parameter |
xor | key |
xor_s | key_1 |
xor_e | key_2 |
public final static byte xorArrays(byte[] src, byte xor, byte xor_s, byte xor_e)
//package com.java2s; /******************************************************************************* * Copyright 2013 Zhang Zhuo(william@TinyGameX.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License./*from w ww . j ava2 s . c o m*/ *******************************************************************************/ public class Main { /** * xor ^ <0-127> * * @param src * @param xor * key * @param xor_s * key_1 * @param xor_e * key_2 */ public final static byte xorArrays(byte[] src, byte xor, byte xor_s, byte xor_e) { if (src == null || src.length == 0) return xor; if ((xor_s & 0xFF) == 0xFF && (xor_e & 0xFF) == 0xFF) return xor;// test else { int length = src.length; for (int i = 0; i < length; i++) { writeByte((src[i] & 0xFF) ^ xor, src, i); xor = (byte) (xor < xor_e ? xor + 1 : xor_s); } return xor; } } public final static int writeByte(int v, byte[] b, int off) { b[off] = (byte) v; return 1; } }