initial commit

This commit is contained in:
Rokas Puzonas 2023-05-11 21:15:11 +03:00
commit 4a6d02b871
2 changed files with 43 additions and 0 deletions

16
README.md Normal file
View File

@ -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

27
main.py Normal file
View File

@ -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)))
""")