//// The algorithm is very simple, that is, each byte is moved, the bit of the shift overflow is retained and saved as a byte for combination with the next byte. Public static void main (string [] ARGs) {byte [] DATA = hex. fromstring ("00e8080000000065289bbaef2ec78ccd0f13571ad01bae68000001bbb00818"); byte [] out = rightshift (data, (byte) 3); system. out. println (hex. tostring (out);} public static byte [] rightshift (byte [] data, byte shiftval) {// 00e80800-> 0000 0000 1110 1000 0000 1000 | left shift-5 -----> 0001 1101 00 byte [] out = new byte [data. length + 1]; int offset = 0; byte first = (byte) (data [0] & 0xff)> shiftval )); out [offset ++] = first; For (INT I = 0; I <data. length-1; I ++) {// right shift 3 // get last 3 bits of this byte. combine these 3 bit as a byte. // that byte or the next shifted [3] Byte // --------------- // overflowed 3 bitbyte overflowed = (byte) (data [I] & 0xff) <(8-shiftval); byte next = (byte) (overflowed | (data [I + 1] & 0xff)> shiftval )); out [offset ++] = next;} return out ;}