Blog

Encrypting part of an Obsidian vault without breaking GitHub sync

October 2026

The problem

My Obsidian vault is a second brain: projects, work, money, health, personal notes. I sync it through GitHub with the Obsidian Git plugin. It is convenient: notes leave the laptop, and in the evening they show up on the phone. The two devices never need to be online at the same time.

The downside is that the whole vault sits in my GitHub account. If the account or a token leaks, everything is readable. So I simply stopped writing the most personal things there, which defeats the point of a second brain.

What I wanted: plain notes on my devices, ciphertext on GitHub, the same sync as before. And it had to work on an iPhone.

What I ruled out

Obsidian Sync. Paid, and the whole idea of not depending on someone else's cloud goes away if everything lives in Obsidian's cloud.

Syncthing. Syncs laptop and phone directly, but only while both are online. That is exactly why I was on GitHub in the first place.

git-crypt. Perfect on desktop: it transparently encrypts chosen files through git filters. But on iPhone, Obsidian Git runs on isomorphic-git, a pure JavaScript git that knows nothing about git-crypt. The phone would receive ciphertext.

Termux or a terminal. Termux is Android-only. A terminal plugin on iPhone is impossible: mobile Obsidian is a webview without Node, and iOS does not let apps spawn other processes.

A fork of Obsidian Git with git-crypt support. The most tempting option, and I turned it down on purpose:

  • it is a large codebase I do not own, and the change would land in the riskiest place, the smudge/clean filters inside isomorphic-git;
  • the fork starts falling behind upstream with the first release;
  • a bug there can corrupt the whole repository;
  • the only benefit is git-crypt compatibility, which I do not need.

The approach: a plugin that never touches git

I split the responsibilities. Obsidian Git keeps syncing. The new plugin, Folder Seal, only encrypts and decrypts, and knows nothing about git.

Health/
  health.md              open note, in git as usual
  documents/  🔒         encrypted folder: not on GitHub at all
_sealed/                 encrypted copies of every 🔒 folder — this is what goes to git

The plugin adds encrypted folders to .gitignore and sends _sealed/ to git instead, with files named like 5e4bf3cc….seal that reveal neither names nor contents. On the device they are ordinary notes: searchable, linkable, nothing special.

The daily loop is pull → Sync → work → Sync → commit and push. Sync compares three states — the last sync, what is on disk now, and what arrived in _sealed/ — and reconciles them.

It is plain JavaScript on top of WebCrypto, with no binaries and no terminal, so it behaves the same on desktop and iPhone. It even reaches the phone by itself, through the .obsidian folder in the same repository.

How the encryption works

  • Master key. Random, locked by the passphrase. The passphrase becomes a key through PBKDF2-SHA-256 with 600,000 iterations, so changing it re-locks only the master key instead of re-encrypting every file.
  • Contents. AES-256-GCM. Every file is authenticated: a damaged file or a wrong key stops the sync before anything is overwritten.
  • File names. An HMAC of the path. Names match across devices but reveal nothing; the real path lives inside the ciphertext.
  • Deterministic IV. The same file produces the same ciphertext, so running Sync again creates no noise in git history. The cost is that identical files are recognisable as identical — the same trade-off git-crypt makes.

What broke

I tested the first version on two clones of a test vault through a separate private repository, then on an iPhone. Here is what came up.

Git corrupted the ciphertext. With core.autocrlf on Windows, git treats small files as text and rewrites their line endings. Fatal for ciphertext. The plugin now marks the sealed folder as binary in .gitattributes.

A second passphrase on a new device. Press Sync on a fresh device before pulling, and the plugin sees an empty folder and offers to create a passphrase. The devices would split onto different keys. Now there is a prominent warning: if you are asked to create a passphrase where one should already exist, pull first.

Git conflicts in binary files. Obsidian Git does commit → pull → push. If the same note changed on two devices, git hit a conflict inside a binary file that nobody can resolve by hand. The fix is to never edit a sealed file in place: every version gets its own name with a content hash, and the old one is deleted. Git then merges two devices' work without conflicts, and the plugin itself notices that a note changed in two places, keeps the local version and saves the other one next to it as note (conflict date).md. Nothing is lost.

CRLF versus LF. The same note with different line endings counted as two versions and produced false conflicts. They are now compared as the same text.

Limitations

  • Sync is manual: a button or a command. Running it automatically around pull and push is planned.
  • The names of encrypted folders are visible on GitHub, in the settings and .gitignore. File names and contents are not.
  • It does not protect against someone holding the unlocked device: there the notes are ordinary files. That is what disk encryption and a phone passcode are for.
  • There is no passphrase recovery. Lose it and the notes are gone, so it lives in a password manager.

Where it ended up

My vault now works like this: open sections go to git as usual, personal folders are encrypted, GitHub sync is unchanged, and it all works on desktop and iPhone. The plugin is open source, version 0.2: github.com/DoZhD1k/folder-seal.

The main lesson for me: sometimes it is better not to build into someone else's tool but to put a small one of your own next to it. Obsidian Git keeps doing what it does, Folder Seal does its part, and neither knows about the other.