Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from random import Random
def generate_bytes_for_seed(seed: int, message: str) -> bytearray:
data = Random(seed)
garbage = Random(34988394)
data.seed(seed)
result = bytearray()
i = 0
while i < len(message):
c = message[i]
if data.randrange(2):
result.append(data.randrange(256) ^ ord(c))
i += 1
else:
result.append(garbage.randrange(256))
return result
seed = 69420
message = 'Your secret message!'
print(f"""import random
random.seed({seed})
print(''.join(chr(random.randrange(256) ^ c)
for c in bytes.fromhex({repr(generate_bytes_for_seed(seed, message).hex().upper())})
if random.randrange(2)))
""")
@artus25200
Copy link

artus25200 commented Jan 6, 2022

Really cool ! Good job

@Ernest1338
Copy link

Ernest1338 commented Jan 6, 2022

Isn't the line 7 redundant as the seed was already set in the line 4?

@SoutrikBandyopadhyay
Copy link

SoutrikBandyopadhyay commented Jan 6, 2022

@Ernest1338 You are right ! That seed definition in line 7 is redundant

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