Skip to main content

pygocryptfs

A Python toolkit for gocryptfs v2 encrypted filesystems, inspired by pycryptomator.

Provides full programmatic and shell-based access to a gocryptfs vault without needing the FUSE driver installed.


Requirements

  • Python ≥ 3.10
  • pycryptodome or pycryptodomeX
pip install pycryptodome

Supported feature flags

Flag Status
HKDF + GCMIV128 ✅ required baseline
EMENames + DirIV ✅ per-directory IV + EME wide-block name encryption (default)
Raw64 ✅ unpadded base64 names
PlaintextNames ✅ unencrypted names
AESSIV ✅ AES-SIV content encryption
XChaCha20Poly1305 ✅ XChaCha20 content encryption (gocryptfs ≥ 2.2)
LongNameMax ✅ configurable long-name threshold
FIDO2 ❌ not supported
Reverse mode ❌ not supported
gocryptfs v1 (no HKDF) ❌ not supported

Interactive shell

python -m pygocryptfs /path/to/vault
# or with explicit password
python -m pygocryptfs --password mypassword /path/to/vault

The shell understands these commands:

Command Description
ls [-b] [-r] [-s NSDE-!] [path ...] List virtual directory contents
cd <dir> Change current virtual directory
pwd Print current virtual directory
cat <file> Decrypt a file to stdout
decrypt [-f] [-m] [-F] <vsrc> ... <real_dest> Decrypt file(s)/dir(s) to the real FS
encrypt [-f] [-m] [-F] <real_src> ... <vdest> Encrypt file(s)/dir(s) into the vault
mkdir [-R] <dir> [...] Create virtual directory/ies
mv <src> [src2 ...] <dest> Move / rename
rm [-f] <path> [...] Remove file(s)/dir(s) (-f = force recursive)
alias <vpath> [...] Show real pathname of a virtual path
backup <zip> Backup all gocryptfs.diriv to a ZIP
quit / exit Exit the shell

Shell wildcards (*, ?) are supported for all commands.

ls sort specifiers

Char Meaning
N by Name
S by Size
D by Date
E by Extension
- reverse subsequent key
! toggle reverse

Single-command mode

python -m pygocryptfs --password secret /vault ls /
python -m pygocryptfs --password secret /vault decrypt /secret.txt /tmp/out.txt
python -m pygocryptfs --password secret /vault encrypt /tmp/myfile.txt /

Initialise a new vault

python -m pygocryptfs --init --password mypassword /path/to/new/vault

Print / backup the master key

# Print in hex (default)
python -m pygocryptfs --password secret --print-key     /vault
# Print in base64
python -m pygocryptfs --password secret --print-key b64 /vault
# Print in ASCII85
python -m pygocryptfs --password secret --print-key a85 /vault

Change the vault password

python -m pygocryptfs --password oldpass --change-password /vault

Programmatic API

from pygocryptfs import Vault, init_vault, backupDirIds

# Open an existing vault
v = Vault('/path/to/vault', password='secret')

# List root
v.ls(['/'])

# Decrypt a file
v.decryptFile('/documents/report.pdf', '/tmp/report.pdf', force=True)

# Encrypt a file
v.encryptFile('/tmp/photo.jpg', '/photos/photo.jpg')

# Walk the virtual filesystem
for root, dirs, files in v.walk('/'):
    print(root, dirs, files)

# Create a directory
v.mkdir('/new_folder')

# Move / rename
v.mv('/old_name.txt', '/new_name.txt')

# Remove
v.remove('/unwanted.txt')
v.rmtree('/old_folder')

# Backup directory IVs
backupDirIds('/path/to/vault', '/tmp/diriv_backup.zip')

Package structure

pygocryptfs/
├── __init__.py       # public API: Vault, init_vault, backupDirIds
├── __main__.py       # CLI entry point
├── gocryptfs.py      # Vault class + all crypto logic
└── gcshell.py        # Interactive shell (GCShell)

License

MIT License – see source files for copyright notices.

Release files for pygocryptfs 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygocryptfs 1.0
File Size Uploaded
pygocryptfs-1.0.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygocryptfs 1.0
File Interpreter ABI Platform
pygocryptfs-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.6 kB

Release files / pygocryptfs-1.0.tar.gz

Download URL pygocryptfs-1.0.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
16968ca9dd990c7d47b0e8344778298d024ee300af7aee8544139e7019f0ef38
BLAKE2b-256 checksum
How to use checksums
c02c9de5b696d2cf77dd06f8e201804a2a4a6dcd0363e9c36c2543b3abe256aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 9, 2026.

Transparency log

Release files / pygocryptfs-1.0-py3-none-any.whl

Download URL pygocryptfs-1.0-py3-none-any.whl
Size 30.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1042a09b0773638345bb9589e554db32562bc4af89a5df583f0f3cab9c15d551
BLAKE2b-256 checksum
How to use checksums
4c732b288496c10237ec77ce59744fc4cfe015ae47ea97e2ff5a2a01921c3a38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page