Empire enigma (What am I doing wrong?)

Here is my algorithm :
- XOR the ASCII of ‘@’ with the first number to get R(offset+1)
- Use the formula to get the others R(N) needed
- XOR the R(N) with their corresponding input number to get the final message

It doesn’t seem to work however, since I’m unable to find the right message at the end.

Here is my code (python) :

import sys

offset = int(raw_input())
length = int(raw_input())
c = []
for i in xrange(length):

b_at = ord(’@’)
R = []
R.append(b_at ^ c[0])

for k in range(1,length):
nombre = (7562100 * R[-1] + 907598307) % 7140
nombre = nombre & 0b11111111

message = “”

for k in range(1, length):
message += chr(c[k] ^ R[k])

print message

What am I doing wrong please?

The statement says:

Each undiscarded random number from the RNG is then XOR’ed with the ASCII code of each character, truncated to the lowest 8 bits.

Hence “@” XOR the first number is not R(offset+1) but R(offset+1) & 0b11111111.
Moreover (this is related to the same misunderstanding), your nombre = nombre & 0b11111111 completely disturbs the RNG (to compute R(i+1), you are supposed to keep the whole R(i), not only its last 8 bits).

Thank you very much, I didn’t realize I was disturbing the RNG.

However, I’m really lost as to how I could find the whole R(offset+1) from its troncated value… Is my method even viable?

Thanks again

Well, you have to find some way to guess/try. It’s hard to give more hints without spoiling the puzzle.

1 Like

Realize that modulo is a bad formula for the empire.

1 Like