Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Solving bitwise XOR and ROR equation

I have been told that x ^ ROR(x, 13) = 0x936f2a8247534566

^ is the XOR operator, like in C, and ROR() is a function that rotates-right the bits of the input by the specified number of positions, like the Intel processor instruction.

The question is how do I find x. It seems a lot of possibilities to try every 64-bit combination, maybe there is a better way?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This algorithm

unsigned long long res = 0;
int bit = 1;
for (int k = 0, shift = 0; k < 64; k++, shift = (shift + 13) % 64)
{
    if (bit)
        res |= 1ull << shift;
    if (0x936f2a8247534566 & (1ull << shift))
        bit = 1 - bit;
}

gives the answer

0x1337b33fdeadb00b

And if we start start with bit = 0, the answer is

0xecc84cc021524ff4

The idea is the following. If the last bit of 0x936f2a8247534566 is 0, it means that bit[13] ^ bit[0] == 0, hence bits are equal. Otherwise bit[0] and bit[13] are different.

The same logic applies to bit[13] and bit[26], etc. So basically the number 0x936f2a8247534566 tells us which bits of the original number are equal to each other and which are not.

Since with step 13 we get all possible positions between 0 and 63(inclusive), we need just one loop.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!