Here you can find the source of matrixToShort(final byte[][] b)
Parameter | Description |
---|
protected static short matrixToShort(final byte[][] b)
//package com.java2s; /** Copyright 2014 Noel Niles * /*ww w . ja v a 2 s. com*/ * This file is part of SAES. * * S-AES 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 3 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ public class Main { /** Converts a 2x2 matrix of nibbles to a 16-bit short. * * Operates columnwise. Example: * * | 0x01 0x03 | * | 0x02 0x04 | == 0x1234 * * @param b: 2x2 array. * @return result: a short **************************************************************************/ protected static short matrixToShort(final byte[][] b) { short result = 0; result = (short) (result | b[0][0]); result = (short) ((result << 4) | b[1][0]); result = (short) ((result << 4) | b[0][1]); result = (short) ((result << 4) | b[1][1]); return result; } }