-
-
Save rexim/81de1139a91839b96f9a65ad05c61406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) | |
""") |
Isn't the line 7 redundant as the seed was already set in the line 4?
@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
Really cool ! Good job