Skip to main content

General purpose Python encrypted file-like object that facilitates random access IO. Uses AES encryption in CTR mode. Can be used with modules such as tarfile, zipfile, lzma, pickle, json and others that accept a file-like object as an alternative to a path. Supports binary IO modes only.

Examples

import cryptfile

with cryptfile.open('data.bin', 'wb+', aes_key=b'256 bit key', block_num=5000) as f:
    f.write(b'Hello, World!')
    f.seek(0)
    print(f.read())

Result:
b'Hello, World!'

Documentation

cryptfile.open(file, mode, aes_key=None, block_num=10000)

Returns a CryptFile object for a specified file.

  • file can either be a string containing a valid path, or a file-like object.
  • Supported mode values are: wb, wb+, rb, rb+, ab, ab+.
  • 256 bit binary aes_key is used for en/decryption, or if none is provided for a new file, a random key is generated and is retrievable with the .aeskey property.
  • block_num sets the number of 16 byte AES blocks per cryptfile block for new files. Each cryptfile block stores its own 8 byte nonce value, and is re-written in whole if any part of the block is altered. Larger block_num values optimize for more sequential IO, whereas smaller values optimize for smaller random IO that jumps around the file. This argument is not needed for opening existing files.

Dependencies

PyCryptodome for AES encryption

Installation

pip install cryptfile

Metadata

Release files for cryptfile 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryptfile 1.0.4
File Size Uploaded Provenance Actions
cryptfile-1.0.4.tar.gz 5.6 kB Without provenance Details for cryptfile-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cryptfile 1.0.4
File Interpreter ABI Platform Actions
cryptfile-1.0.4-py3-none-any.whl Python 3 none any Details for cryptfile-1.0.4-py3-none-any.whl

Total release size: 23.4 kB

Release files / cryptfile-1.0.4.tar.gz

Download URL cryptfile-1.0.4.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7c8986a0644511e56e307e2aa4566408e8c7de404d0eab26a9982ad41ae3bba6
BLAKE2b-256 checksum
How to use checksums
afc143566796812885d94cb00c4555e9cf69dc7c1247443e4b9404addfd5ad5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release files / cryptfile-1.0.4-py3-none-any.whl

Download URL cryptfile-1.0.4-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09388cfe14cd6efcf63b551ef28fb9835e06875b1bc01743654a190cd99b977d
BLAKE2b-256 checksum
How to use checksums
cefe1d5706871812aff3ab126bfcbc168772f3fb3ac4099511cde31b1dab205f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Security for cryptfile 1.0.4

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page