Java Integer Create toIntArray(byte[] input)

Here you can find the source of toIntArray(byte[] input)

Description

Rewrite a byte array as an int array (the array can be padded with zeros)

License

Open Source License

Parameter

Parameter Description
input - the byte array

Return

int array

Declaration

public static int[] toIntArray(byte[] input) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008 JCrypTool Team and Contributors
 * //from   ww w .ja v a2s .co  m
 * 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 {
    /**
     * Rewrite a byte array as an int array (the array can be padded with zeros)
     * 
     * @param input - the byte array
     * @return int array
     */
    public static int[] toIntArray(byte[] input) {
        int[] result = new int[(input.length + 3) >>> 2];
        int index, shiftpos;
        for (int i = 0; i < input.length; i++) {
            index = i >>> 2;
            shiftpos = i % 4;
            result[index] ^= (input[i] & 0xff) << (8 * shiftpos);
        }
        return result;
    }
}

Related

  1. toIntArray(byte[] bytes)
  2. toIntArray(byte[] data)
  3. toIntArray(byte[] data)
  4. toIntArray(byte[] data, boolean includeLength)
  5. toIntArray(byte[] data, int offset)
  6. toIntArray(double[] a)
  7. toIntArray(double[] array)
  8. toIntArray(final byte[] array)
  9. toIntArray(final byte[] bytes)