NaclFile
A python xxxFile like (ie TarFile, GzipFile, BZ2File, pyzstd.ZstdFile, ...) for encrypting files with PyNacl SecretBox.
This project is part of the CofferFile : https://github.com/bibi21000/CofferFile.
If you're looking for a more powerfull storage for your sensible datas, look at PyCoffer : https://github.com/bibi21000/PyCoffer.
Install
pip install naclfile
Create your encryption key
from nacl import utils
key = utils.random(SecretBox.KEY_SIZE)
and store it in a safe place (disk, database, ...).
This key is essential to encrypt and decrypt data. Losing this key means losing the data.
"open" your encrypted files like normal files
Text files :
from naclfile import open as nacl_open
with nacl_open('test.nacl', mode='wt', secret_key=key, encoding="utf-8") as ff:
ff.write(data)
with nacl_open('test.nacl', "rt", secret_key=key, encoding="utf-8") as ff:
data = ff.read()
with nacl_open('test.nacl', mode='wt', secret_key=key, encoding="utf-8") as ff:
ff.writelines(data)
with nacl_open('test.nacl', "rt", secret_key=key, encoding="utf-8") as ff:
data = ff.readlines()
Binary files :
with nacl_open('test.nacl', mode='wb', secret_key=key) as ff:
ff.write(data)
with nacl_open('test.nacl', "rb", secret_key=key) as ff:
data = ff.read()
Crypt and compress ... for better performances.
Look at https://github.com/bibi21000/CofferFile/blob/main/BENCHMARK.md.
from naclfile.zstd import open as nacl_open
with nacl_open('test.nacz', mode='wb', secret_key=key) as ff:
ff.write(data)
with nacl_open('test.nacz', "rb", secret_key=key) as ff:
data = ff.read()
Crypt and compress your tar files
from naclfile.tar import open as tar_open
with tar_open('test.tarcz', mode='w', secret_key=key) as ff:
ff.add(file1,'file1.data')
ff.add(file2,'file2.data')
with tar_open('test.tarcz', "r", secret_key=key) as ff:
ff.extractall()
Look at documentation : https://bibi21000.github.io/NaclFile/
Metadata
Release files for naclfile 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| naclfile-0.0.6.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| naclfile-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.0 kB
Release files / naclfile-0.0.6.tar.gz
| Download URL | naclfile-0.0.6.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf16cb6fbe11b8b06c464e4a61df19e3c650641cc15fabb9dff1455c2e127cef
|
|
BLAKE2b-256 checksum How to use checksums |
6c43a5f0db0b77defe99364b0a72dc8591ca572d3b879551104733080947760c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 8, 2025.
Transparency logRelease files / naclfile-0.0.6-py3-none-any.whl
| Download URL | naclfile-0.0.6-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afa9857498b93c32bcbb8ac4c02e0b4d09a780cbe4f2aef88d459a3b8d01ee5d
|
|
BLAKE2b-256 checksum How to use checksums |
1333845f9621de06bcceed97ebf94e530134006b66fd4f0fc7c9a51f6f7def30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 8, 2025.
Transparency log