Here you can find the source of toIntBigEndian(byte[] input)
Parameter | Description |
---|---|
input | - the byte array |
public static int toIntBigEndian(byte[] input)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 JCrypTool Team and Contributors * /* w w w . ja v a 2s .c om*/ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse * Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ public class Main { /** * Convert a byte array of length 4 into an int number, using big-endian notation * * @param input - the byte array * @return the converted int or <tt>0</tt> if <tt>input.length != 4</tt> */ public static int toIntBigEndian(byte[] input) { int result = 0; if (input.length != 4) { return 0; } result ^= (input[0] & 0xff) << 24; result ^= (input[1] & 0xff) << 16; result ^= (input[2] & 0xff) << 8; result ^= input[3] & 0xff; return result; } }