Skip to main content

A python xxxFile like (ie GzipFile, BZ2File, ...) for manipulating Nacl encrypted files.

Project description

CircleCI codecov PyPI - Downloads

NaclFile

This project is part of the CofferFile : https://github.com/bibi21000/CofferFile

Encrypt your files with PyNacl SecretBox.

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 :

    import naclfile.zstd

    with naclfile.zstd.open('test.nacz', mode='wb', secret_key=key) as ff:
        ff.write(data)

    with naclfile.zstd.open('test.nacz', "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/

Project details


Download files

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

Source Distribution

naclfile-0.0.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

naclfile-0.0.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file naclfile-0.0.2.tar.gz.

File metadata

  • Download URL: naclfile-0.0.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for naclfile-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e1bc295eb355a604b2d7ba2c476372978ec4d1c06be750787702d4677ce9f271
MD5 68cb825362725557a99802e1dad1bfeb
BLAKE2b-256 e6209c1e983cd9d78e5f9f3ab26462c09fdacfc626e7332f25635c5d80208b1b

See more details on using hashes here.

File details

Details for the file naclfile-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: naclfile-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for naclfile-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e92299543d01cb5d9fa6bd21dd46d76d1776d666f0cb640e84f90d880d971ddb
MD5 22c68c15f7f1f9f937ea02c0a0d8945a
BLAKE2b-256 8006bb743246a401c6c62360b8b6a60ced3a5a418479930ec4f62126c37f602b

See more details on using hashes here.

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