Module refinery.units.blockwise.rotr

Expand source code Browse git
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from . import BinaryOperation


class rotr(BinaryOperation):
    """
    Rotate the bits of each block right.
    """
    def operate(self, value, shift):
        shift %= self.fbits
        return (value >> shift) | (value << (self.fbits - shift))

    def inplace(self, value, shift):
        shift %= self.fbits
        lower = value >> shift
        value <<= self.fbits - shift
        value |= lower

Classes

class rotr (argument, bigendian=False, blocksize=1)

Rotate the bits of each block right.

Expand source code Browse git
class rotr(BinaryOperation):
    """
    Rotate the bits of each block right.
    """
    def operate(self, value, shift):
        shift %= self.fbits
        return (value >> shift) | (value << (self.fbits - shift))

    def inplace(self, value, shift):
        shift %= self.fbits
        lower = value >> shift
        value <<= self.fbits - shift
        value |= lower

Ancestors

Methods

def operate(self, value, shift)
Expand source code Browse git
def operate(self, value, shift):
    shift %= self.fbits
    return (value >> shift) | (value << (self.fbits - shift))
def inplace(self, value, shift)
Expand source code Browse git
def inplace(self, value, shift):
    shift %= self.fbits
    lower = value >> shift
    value <<= self.fbits - shift
    value |= lower

Inherited members