Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda