Access a gocryptfs v2 vault with pure Python
Project description
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
pycryptodomeorpycryptodomeX
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygocryptfs-1.0.tar.gz.
File metadata
- Download URL: pygocryptfs-1.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16968ca9dd990c7d47b0e8344778298d024ee300af7aee8544139e7019f0ef38
|
|
| MD5 |
5e798553b82d38f302b52058a4649308
|
|
| BLAKE2b-256 |
c02c9de5b696d2cf77dd06f8e201804a2a4a6dcd0363e9c36c2543b3abe256aa
|
Provenance
The following attestation bundles were made for pygocryptfs-1.0.tar.gz:
Publisher:
python-publish.yml on maxpat78/pygocryptfs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygocryptfs-1.0.tar.gz -
Subject digest:
16968ca9dd990c7d47b0e8344778298d024ee300af7aee8544139e7019f0ef38 - Sigstore transparency entry: 1066472836
- Sigstore integration time:
-
Permalink:
maxpat78/pygocryptfs@888b8f09bf35f4faf48821b30800481375fda1e1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/maxpat78
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@888b8f09bf35f4faf48821b30800481375fda1e1 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pygocryptfs-1.0-py3-none-any.whl.
File metadata
- Download URL: pygocryptfs-1.0-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1042a09b0773638345bb9589e554db32562bc4af89a5df583f0f3cab9c15d551
|
|
| MD5 |
deced39edaac1d1e71a7f0e9b13e33cb
|
|
| BLAKE2b-256 |
4c732b288496c10237ec77ce59744fc4cfe015ae47ea97e2ff5a2a01921c3a38
|
Provenance
The following attestation bundles were made for pygocryptfs-1.0-py3-none-any.whl:
Publisher:
python-publish.yml on maxpat78/pygocryptfs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygocryptfs-1.0-py3-none-any.whl -
Subject digest:
1042a09b0773638345bb9589e554db32562bc4af89a5df583f0f3cab9c15d551 - Sigstore transparency entry: 1066472847
- Sigstore integration time:
-
Permalink:
maxpat78/pygocryptfs@888b8f09bf35f4faf48821b30800481375fda1e1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/maxpat78
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@888b8f09bf35f4faf48821b30800481375fda1e1 -
Trigger Event:
workflow_dispatch
-
Statement type: