Android Utililty Methods Byte Array Rotate

List of utility methods to do Byte Array Rotate

Description

The list of methods to do Byte Array Rotate are organized into topic(s).

Method

byte[]rotateLeft(byte[] input)
Moves all bytes one up, meaning the left most byte (0) is swapped to the end
byte[] cycled = new byte[input.length];
System.arraycopy(input, 1, cycled, 0, input.length - 1);
cycled[cycled.length - 1] = input[0];
return cycled;
byte[]rotateRight(byte[] input)
Moves all bytes one down, meaning the right most byte (length-1) is swapped to the beginning
byte[] cycled = new byte[input.length];
System.arraycopy(input, 0, cycled, 1, input.length - 1);
cycled[0] = input[input.length - 1];
return cycled;
byte[]unrotate(byte[] data, int blockSizeBytes)
Unrotate data.
byte result[] = new byte[data.length];
int numBlocks = data.length / blockSizeBytes;
for (int block = 0; block < numBlocks; block++) {
    for (int el = 0; el < blockSizeBytes; el++) {
        result[el * numBlocks + block] = data[block
                * blockSizeBytes + el];
return result;