8-bit mask with cyclic left shift:
shifted = number << 1 overflowed = (number & 0x100) >> 8 shifted &= 0xFF result = overflowed | shifted
You should be able to create a class that does this for you. With a little more than that, it can shift an arbitrary amount from an arbitrary size.
source share