π 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
- 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.
- Natural Carrier Prose (News & Poetry):
- Dynamic grammatical sentence construction prevents structural repetition within subsequent sentences.
- Context continuation probabilities prevent unnatural keyword clustering.
- 100% Losslessly Reversible:
- Power-of-two slot allocation guarantees bit-exact extraction without precision drift.
- Adaptive Compression:
- Transparent pre-encryption payload compression with
gzipor common-word dictionary packing.
- Transparent pre-encryption payload compression with
π¦ 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>
π Project Links
- GitHub Repository: https://github.com/3-ark/ngram-cipher
- License: MIT