Java Array Shift shiftLeft(byte[] block, byte[] output)

Here you can find the source of shiftLeft(byte[] block, byte[] output)

Description

Code taken from org.bouncycastle.crypto.macs.CMac

License

Open Source License

Declaration

private static int shiftLeft(byte[] block, byte[] output) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Sebastian Stenzel/*from  w  w  w. jav a  2s .  co m*/
 * This file is licensed under the terms of the MIT license.
 * See the LICENSE.txt file for more info.
 * 
 * Contributors:
 *     Sebastian Stenzel - initial API and implementation
 ******************************************************************************/

public class Main {
    /**
     * Code taken from {@link org.bouncycastle.crypto.macs.CMac}
     */
    private static int shiftLeft(byte[] block, byte[] output) {
        int i = block.length;
        int bit = 0;
        while (--i >= 0) {
            int b = block[i] & 0xff;
            output[i] = (byte) ((b << 1) | bit);
            bit = (b >>> 7) & 1;
        }
        return bit;
    }
}

Related

  1. ShiftAwayTrailingZerosTwoElements(int[] arr)
  2. shiftChroma(float[] chroma, int step)
  3. shiftEnum(E current, E[] values, int delta)
  4. shiftLeft(byte[] array)
  5. shiftLeft(byte[] b1, int bytes)
  6. shiftLeft(byte[] data, int shiftBy)
  7. shiftLeft(Object[] arr, int startIndex, int endIndex)
  8. shiftLeft(Object[] array, int amount)
  9. shiftLeft(Object[] object)