# Open Message This programm obfuscates a message, using another text message. Where `message` is a piece of text you want to obfuscate. And where `container` is some text, which will be used for the obfuscation. Both will result in a new file, which is the `key`. Basically, for encoding: `k = m + c`. And for decoding: `m = c - k`. > [!WARNING] > This project is just an experiment on permutations and byte manipulation. > It does not provide any secure encryption. > It only obfuscates text, which adds no security layer. ## Build For the current OS: `cargo build --release` ## Usage Encoding: `$ om container.txt -e message.txt` Decoding: `$ om container.txt -d key.om` Decode, don't print the message, and save the message to a file: `$ om container.txt -sod key.om` ## How it works ### Encoding 1. Define two strings, where: ```text ::= "the message you want to hide" ::= "the text, where the message will be hidden" ``` 2. Define the global size of all byte chunks: ` ::= 4` 3. Precompute the permutation of `CHUNK_SIZE` using the [Steinhaus-Johnson-Trotter algorithm](https://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm) 4. Split `message` into chunks of `CHUNK_SIZE` 5. Split `container` into padded chunks of `CHUNK_SIZE` ```python container = [[0x48, 0x65, 0x6c, 0x6c], [0x6f, 0x00, 0x00, 0x00]] message = [[0x54, 0x65, 0x73, 0x74]] ``` 6. Calculate if the message fits into the container: ```python ceil(permutations.length / message.chunks.length) > container.chunks.length ``` 7. Choose a random position inside the container chunks, where to start encoding from. 8. Iterate over `container.chunks`, apply the permutation over the current `container.chunk`, and `xor` each permutation with `message.chunk[idx]`, if the permutation is exhausted, go to the next `container.chunk` repeat till `message.chunks` is exhausted. 9. Store the xor'ed value, where: ` ::= ` ```text Message Chunks -> [[A, B, C, D], [E, F, G, H], [I, J, K, L], ...] Container Chunks -> [[1, 2, 3, 4], [5, 6, 7, 8], ...] // one iteration Container Chunk -> [ 1 2 3 4 ] P1 1 2 4 3 xor A B C D P2 1 4 2 3 xor E F G H P3 4 1 2 3 xor I J K L .. ... ... ... ``` 10. Generate the header with the position information from Step n, and magic identification value, where: ``` ::= ::= ::= "OMfmt" ``` 11. Append the `key` with the header 12. Compress the header + `key` using DEFLATE 13. Save it as a file