Skip to main content

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
  • 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.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygocryptfs-1.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygocryptfs-1.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

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

Hashes for pygocryptfs-1.0.tar.gz
Algorithm Hash digest
SHA256 16968ca9dd990c7d47b0e8344778298d024ee300af7aee8544139e7019f0ef38
MD5 5e798553b82d38f302b52058a4649308
BLAKE2b-256 c02c9de5b696d2cf77dd06f8e201804a2a4a6dcd0363e9c36c2543b3abe256aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygocryptfs-1.0.tar.gz:

Publisher: python-publish.yml on maxpat78/pygocryptfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pygocryptfs-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1042a09b0773638345bb9589e554db32562bc4af89a5df583f0f3cab9c15d551
MD5 deced39edaac1d1e71a7f0e9b13e33cb
BLAKE2b-256 4c732b288496c10237ec77ce59744fc4cfe015ae47ea97e2ff5a2a01921c3a38

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygocryptfs-1.0-py3-none-any.whl:

Publisher: python-publish.yml on maxpat78/pygocryptfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page