Circular shift

Circular shifts are used often in cryptography in order to permute bit sequences.

Unfortunately, many programming languages, including C, do not have operators or standard functions for circular shifting, even though virtually all processors have bitwise operation instructions for it (e.g. Intel x86 has ROL and ROR).

However, some compilers may provide access to the processor instructions by means of intrinsic functions.

[1][2] This safe and compiler-friendly implementation was developed by John Regehr,[3] and further polished by Peter Cordes.

If the bit sequence 0001 0111 were subjected to a circular shift of one bit position... (see images below) If the bit sequence 1001 0110 were subjected to the following operations: Cyclic codes are a kind of block code with the property that the circular shift of a codeword will always yield another codeword.

Left circular shift.
Right circular shift.