Skip to content

Instantly share code, notes, and snippets.

@yarjor
Last active September 14, 2018 14:29
Show Gist options
  • Select an option

  • Save yarjor/c80fe2a08558d53133416f15a1149841 to your computer and use it in GitHub Desktop.

Select an option

Save yarjor/c80fe2a08558d53133416f15a1149841 to your computer and use it in GitHub Desktop.
[ROR & ROL] #re #reverse-engineering #operations #opcode #rotate
def rol(val, r_bits, max_bits):
return (val << r_bits % max_bits) & (2 ** max_bits - 1) | ((val & (2 ** max_bits - 1)) >> (max_bits - (r_bits % max_bits)))
def ror(val, r_bits, max_bits):
return ((val & (2 ** max_bits - 1)) >> r_bits % max_bits) | (val << (max_bits - (r_bits % max_bits)) & (2 ** max_bits - 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment