CRYPT_DIR
- Encrypt all your files and write into another directory if there is update
- Clean the encrypted directory if files or directories have been deleted
- Restore
- Minimize writing to SSDs
USAGE
- encrypt
# User maintains two directories plain_dir and encrypted_dir
import crypt_dir
plain_dir = "plain"
encrypted_dir = "encrypted"
restored_dir = "restored"
key = crypt_dir.make_key_from_passphrase(b"passphrase1234")
# Delete all files, directories in encrypted_dir that don't exist in the plain_dir
crypt_dir.clean_encrypted_dir(
plain_dir=plain_dir,
encrypted_dir=encrypted_dir,
)
# read files in plain_dir, encrypt and write files into encrypted_dir if needed using 12 workers
crypt_dir.update_encrypted_dir(
key=key,
plain_dir=plain_dir,
encrypted_dir=encrypted_dir,
max_workers=12,
)
- restore
import crypt_dir
plain_dir = "plain"
encrypted_dir = "encrypted"
restored_dir = "restored"
key = crypt_dir.make_key_from_passphrase(b"passphrase1234")
# restore all files in encrypted_dir using 12 workers
crypt_dir.restore_encrypted_dir(
key=key,
encrypted_dir=encrypted_dir,
restored_dir=restored_dir,
max_workers=12,
)
- certificate
import crypt_dir
correct_passphrase = b"passphrase123"
cert = crypt_dir.make_certificate(correct_passphrase)
print("cert", cert)
try:
wrong_passphrase = b"passphrase456"
_ = crypt_dir.verify_certificate(cert, wrong_passphrase)
except AssertionError as e:
print("expected assertion error: ", e)
key = crypt_dir.verify_certificate(cert, correct_passphrase)
print("generated key from correct passphrase", key)
INSTALLATION
pip install --upgrade crypt-dir
DECRYPT IT YOURSELF
SPECIFICATION 1.*
You don't need to know the specification. For some folks who want to know exactly what happened with their files, here
is the specification for key_file and .enc1 files:
-
if
key_filedoes not exist,crypt_dirwill create a random key of 32 bytes usingos.urandomencoded intohex -
two algorithms are used in
crypt_dir:SHA1andAES-256inCBCmode -
encrypted files are updated only if file is modified (mtime changes)
-
file is decrypt-able if
signaturematcheskey -
.enc1file-
header:file_sig: little-endian encoded mtime of file in uint64key_sig:SHA1bytes of keyfile_size: little-endian encoded file size in uint64init_vec:AES256initialization vector
-
file encrypted:AES256file encrypted bytes with chunk size of2^30
-
__________________________________________________________________________________
| header | encrypted_data |
|___________________________________________________________|____________________|
| file_sig | key_sig | file_size | init_vec | encrypted_data |
| 8 bytes | 20 bytes | 8 bytes | 16 bytes | n bytes |
|___________________________________________________________|____________________|
SPECIFICATION 0.*
You don't need to know the specification. For some folks who want to know exactly what happened with their files, here
is the specification for key_file and .enc files:
-
if
key_filedoes not exist,crypt_dirwill create a random key of 32 bytes usingos.urandomencoded intohex -
two algorithms are used in
crypt_dir:SHA1andAES-256inCBCmode -
encrypted files are updated only if file_hash changes
-
file is decrypt-able if
signaturematcheskey -
.encfilesignature:SHA1bytes of keyfile_hash:SHA1bytes of filefile_size: little-endian encoded file size in uint64iv:AES256initialization vectorfile encrypted:AES256file encrypted bytes with chunk size of2^30
| signature | file_hash | file_size | iv | encrypted_data |
| 20 bytes | 20 bytes | 8 bytes | 16 bytes | n bytes |
UPLOAD
rm -rf dist crypt_dir.egg-info
python setup.py sdist
twine upload dist/*
Metadata
Release files for crypt-dir 1.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| crypt-dir-1.1.12.tar.gz | 7.7 kB | Without provenance | Details |
Release files / crypt-dir-1.1.12.tar.gz
| Download URL | crypt-dir-1.1.12.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6188c6b79d01759c78c2fe9954c78ebac57704d7f29874ef747600a9e2bde8d
|
|
BLAKE2b-256 checksum How to use checksums |
99b3eb064d3b4cf1ca5a36d07d7e3ea780b16571d6eb952b22f06f9f4852f7a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for crypt-dir 1.1.12
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.