Method: Rex::Text.ror

Defined in:
lib/rex/text/binary_manipulation.rb

.ror(val, cnt) ⇒ Object

Rotate a 32-bit value to the right by cnt bits

Parameters:

  • val (Integer)

    The value to rotate

  • cnt (Integer)

    Number of bits to rotate by



76
77
78
79
80
81
82
# File 'lib/rex/text/binary_manipulation.rb', line 76

def self.ror(val, cnt)
  bits = [val].pack("N").unpack("B32")[0].split(//)
  1.upto(cnt) do |c|
    bits.unshift( bits.pop )
  end
  [bits.join].pack("B32").unpack("N")[0]
end