N-Gram Cipher - Steganographic Encryption

πŸ” Natural English N-Gram Cipher

ngram-cipher is an open-source TypeScript & JavaScript steganography engine that encrypts secret payloads using AES-256-GCM and conceals the resulting ciphertext directly within losslessly reversible, grammatically natural English prose, poetry, or ONNX neural language model tokens.


⚑ Interactive Cipher Encoder & Decoder

Test the cipher engine directly in your browser. Select your preferred carrier style belowβ€”from statistical news prose and poetry stanzas to experimental causal language models:


πŸ”‘ Key Architectural Features

  1. Robust Cryptography:
    • Key derivation using PBKDF2 with 100,000 SHA-256 iterations.
    • Symmetric authenticated encryption via AES-256-GCM.
    • Binary frame verification with CRC32 checksums and keystream whitening.
  2. Natural Carrier Prose (News & Poetry):
    • Dynamic grammatical sentence construction prevents structural repetition within subsequent sentences.
    • Context continuation probabilities prevent unnatural keyword clustering.
  3. 100% Losslessly Reversible:
    • Power-of-two slot allocation guarantees bit-exact extraction without precision drift.
  4. Adaptive Compression:
    • Transparent pre-encryption payload compression with gzip or common-word dictionary packing.

πŸ“¦ Installation & Usage

Install the package via npm:

npm install ngram-cipher

Modern ESM / TypeScript

import { encode, decode } from "ngram-cipher";

// 1. Encode into journalistic news prose
const carrier = await encode("Classified update at midnight", "StrongPassword123");
console.log(carrier);
/*
"The critical market expanded 15.0% in Paris. Johnson stated that the central bank
raised interest rates 5.1%, but the agency rejected the proposal..."
*/

// 2. Decode back to original secret text
const plaintext = await decode(carrier, "StrongPassword123");
console.log(plaintext); // "Classified update at midnight"

Browser Script Tag

Include the global build directly from our site:

<script src="/assets/js/ngram-cipher.global.js"></script>
<script>
  window.ngramCipher.encode("My Secret", "password").then(console.log);
</script>