This is a text steganography library for JavaScript adapted from Hernan Moraldo's reference implementation for “An Approach for Text Steganography Based on Markov Chains”. This method produces more natural looking and less easily detectable texts than other Markov-based systems.
In this implementation, n-gram models support updating and n values of ≥ 1.
An online interactive demo is available here.
<script src="markovTextStego.js"></script>
Initial setup:
var stego = new MarkovTextStego();
Create n-gram model:
var model = new stego.NGramModel(n);
// Import corpus (an array of strings: messages, lines, paragraphs, etc.)
model.import(corpus);
Initialise the Codec:
var codec = new stego.Codec(model);
Encode & Decode:
codec.encode('Hello World!');
codec.decode('The Achaeans. And with a moderate force of which one has to remark that men ought either to the kingdom! In exchange for the priesthood? Were San Pietro ad Vincula. He was obliged to avoid one trouble without running into another but prudence consists in knowing how lukewarm he was priest and that those men who were besieging Gaeta. In charge of Messer Antonio the priest to the shoulders of the counsellors will think of himself.');
Update the model with an array of additional corpus text:
model.update(additionalCorpus);
Change the model to a different one:
codec.setModel(newModel);
- Corpus must contain at least two unique sentences/lines with each consisting of two or more words.
- Hernan Moraldo (@hmoraldo)
- Umair Idris (@umairidris)