commit 4a6d02b871915d9a2422feb6936ce03b6be19055 Author: Rokas Puzonas Date: Thu May 11 21:15:11 2023 +0300 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..46bab91 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Secret message generator + +This uses the fact that all random number generation is pseudo-random, to create a script that +generates some python code which takes a seemingly random sequence of symbols to create a message when ran. + +Example output: +```python +import random +random.seed(69420) +print(''.join(chr(random.randrange(256) ^ c) + for c in bytes.fromhex('EAEE924CC3218C27D1EB90648D37606EDA21C1782B25C6F789C0A7BFBE') + if random.randrange(2))) +``` +This would output: "Hello, World!" + +TODO: Create a Web interface for generating these snippets of code easily diff --git a/main.py b/main.py new file mode 100644 index 0000000..53e4685 --- /dev/null +++ b/main.py @@ -0,0 +1,27 @@ +#!/bin/python3 +from random import Random +import random + +def generate_bytes_for_seed(seed: int, message: str) -> bytearray: + data = Random(seed) + + 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(random.randrange(256)) + return result + +seed = 69420 +message = 'Hello, World!' +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))) +""")