Skip to content

Instantly share code, notes, and snippets.

@arkku
Last active August 29, 2015 14:25
Show Gist options
  • Save arkku/bf65447fdd035934cf79 to your computer and use it in GitHub Desktop.
Save arkku/bf65447fdd035934cf79 to your computer and use it in GitHub Desktop.
ROR puzzle
uint32_t ror(const uint32_t w, const unsigned rot) { // ROtate Right (bits move `rot` places right w/ wraparound)
return (w >> rot) | (w << (32 - rot));
}
uint32_t a; // = ?
uint32_t rotation = 13;
uint32_t b = 0x29d34b82;
// b == a ^ ror(a, rotation)
// What is `a` when `b` was formed by `a ^ ror(a, rotation)`? There is more than one correct answer.
@arkku
Copy link
Author

arkku commented Jul 17, 2015

^ is the bitwise XOR operator, the function ror rotates bits to the right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment