{"slug": "i-dna-encode-my-encrypted-database-before-writing-it-to-disk-here-s-why-and-why", "title": "I DNA-encode my encrypted database before writing it to disk - here's why (and why it's not \"quantum\" anything)", "summary": "A developer built mdc-lite, a ~348KB embeddable encrypted key-value store in Rust that encodes ciphertext as DNA-like A/C/G/T strings before writing to disk. The design, part of the ModelDB repo, uses XChaCha20-Poly1305 encryption and BLAKE3-hashed filenames to prevent metadata leakage, aiming for secure storage on devices without server access.", "body_md": "Every value in my little embedded key-value store gets encrypted, then\n\nits ciphertext gets encoded as a string of A/C/G/T characters before it\n\never touches the filesystem. Open the file in a text editor and you'll\n\nsee actual DNA-looking text - not because it's a gimmick, but because\n\nthat's genuinely the storage format.\n\nThis is `mdc-lite`\n\n, a ~348KB embeddable encrypted key-value store I\n\nbuilt in Rust for places a server can't reach - a watch face, a phone\n\napp, a background service. It's part of a larger repo, [ModelDB](https://github.com/saji1970/ModelDB),\n\nthat also includes MDC, a Python conversational data engine (query AI\n\nmodels, databases, images, and documents in plain English, no SQL) with\n\nits own DNA-inspired archival storage tier.\n\nEvery `put()`\n\ncall does this, in order:\n\n`[key_len][key_bytes][value_bytes]`\n\ninto one plaintext buffer.`[nonce][ciphertext][tag]`\n\nblob: 2 bits per\nbase, `00→A 01→C 10→G 11→T`\n\n. Every byte maps to exactly 4 bases, so\nthere's no padding ambiguity on decode.Filenames are keyed BLAKE3 hashes of the logical key, not the key name\n\nitself, so a directory listing alone leaks nothing - no key names, no\n\nvalues, no way to tell how many distinct keys exist versus how many\n\nfiles are on disk.\n\n``` php\nrust\npub fn put(&self, key: &str, value: &[u8]) -> Result<(), LiteStoreError> {\n    let mut plaintext = Vec::new();\n    plaintext.extend_from_slice(&(key.len() as u16).to_le_bytes());\n    plaintext.extend_from_slice(key.as_bytes());\n    plaintext.extend_from_slice(value);\n\n    let nonce = XChaCha20Poly1305::generate_nonce(&mut OsRng);\n    let ciphertext = self.cipher().encrypt(&nonce, plaintext.as_ref())?;\n\n    let mut record = nonce.to_vec();\n    record.extend_from_slice(&ciphertext);\n    let acgt_text = dna::encode(&record); // <- the actual bytes on disk\n\n    fs::write(tmp_path, &acgt_text)?;\n    fs::rename(tmp_path, final_path)?;\n    Ok(())\n}\n```\n\n", "url": "https://wpnews.pro/news/i-dna-encode-my-encrypted-database-before-writing-it-to-disk-here-s-why-and-why", "canonical_source": "https://dev.to/saji1970/i-dna-encode-my-encrypted-database-before-writing-it-to-disk-heres-why-and-why-its-not-3fa3", "published_at": "2026-08-30 12:18:59+00:00", "updated_at": "2026-08-30 12:52:55.016537+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["mdc-lite", "ModelDB", "Rust", "XChaCha20-Poly1305", "BLAKE3"], "alternates": {"html": "https://wpnews.pro/news/i-dna-encode-my-encrypted-database-before-writing-it-to-disk-here-s-why-and-why", "markdown": "https://wpnews.pro/news/i-dna-encode-my-encrypted-database-before-writing-it-to-disk-here-s-why-and-why.md", "text": "https://wpnews.pro/news/i-dna-encode-my-encrypted-database-before-writing-it-to-disk-here-s-why-and-why.txt", "jsonld": "https://wpnews.pro/news/i-dna-encode-my-encrypted-database-before-writing-it-to-disk-here-s-why-and-why.jsonld"}}