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
- Define two strings, where:
<message> ::= "the message you want to hide"
<container> ::= "the text, where the message will be hidden"
- Define the global size of all byte chunks:
<CHUNK_SIZE> ::= 4 - Precompute the permutation of
CHUNK_SIZEusing the Steinhaus-Johnson-Trotter algorithm - Split
messageinto chunks ofCHUNK_SIZE - Split
containerinto padded chunks ofCHUNK_SIZE
container = [[0x48, 0x65, 0x6c, 0x6c],
[0x6f, 0x00, 0x00, 0x00]]
message = [[0x54, 0x65, 0x73, 0x74]]
- Calculate if the message fits into the container:
ceil(permutations.length / message.chunks.length) > container.chunks.length
-
Choose a random position inside the container chunks, where to start encoding from.
-
Iterate over
container.chunks, apply the permutation over the currentcontainer.chunk,
andxoreach permutation withmessage.chunk[idx],
if the permutation is exhausted, go to the nextcontainer.chunk
repeat tillmessage.chunksis exhausted. -
Store the xor'ed value, where:
<key> ::= <Vector of Bytes>
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
.. ... ... ...
- Generate the header with the position information from Step n, and magic identification value, where:
<position> ::= <integer>
<identification> ::= <magic_value>
<magic_value> ::= "OMfmt"
- Append the
keywith the header - Compress the header +
keyusing DEFLATE - Save it as a file