Metadata-Version: 2.1
Name: buffered-encryption
Version: 0.0.2
Summary: Encrypt large files without loading the entire file into memory.
Home-page: https://github.com/eblocha/buffered-encryption
Author: Elliott Blocha
License: MIT
Keywords: cryptography,big,large,encryption
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Topic :: Utilities
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.6, <4
Description-Content-Type: text/markdown
Requires-Dist: cryptography

Buffered Encryption
===================

Encrypt large data files chunk-by-chunk, securely.

This package uses AES in GCM mode to encrypt and decrypt file streams.

It relies on the cryptography library to perform the encryption.

```
big unencrypted file, verification data --> encrypt and sign --> encrypted file, iv, tag

big unencrypted file <-- decrypt and verify <-- encrypted file, iv, tag, verification data
```

Example
-------
```python
import os
from buffered_encryption import EncryptionIterator, DecryptionIterator

plaintext = open("plain.txt","rb")

key = os.urandom(32)
sig = os.urandom(12)

enc = EncryptionIterator(plaintext,key,sig)
with open("cipher","wb") as ciphertext:
    for chunk in enc:
        ciphertext.write(chunk)

plaintext.close()

ciphertext = open("cipher","rb")

dec = DecryptionIterator(ciphertext,key,sig,enc.iv,enc.tag)
with open("plain.dec.txt","wb") as decrypted:
    for chunk in dec:
        decrypted.write(chunk)

ciphertext.close()
```

Classes
-------
```python
class EncryptionIterator:
    """
    Encrypt a file iteratively

    Parameters
    ----------
    plaintext : io.BytesIO
        The file buffer to encrypt
    key : bytes
        The secret key for AES encryption
    signature : bytes
        Additional data used to verify the key later
    chunk_size : int
        How much data to encrypt per iteration

    Attributes
    ----------
    iv : bytes
        The 12-byte initialization vector for GCM. You will need this value for decryption.
    tag : bytes
        The tag to verfiy data integrity on decryption
    """
```

```python
class DecryptionIterator:
    """
    Decrypt a file iteratively

    Parameters
    ----------
    ciphertext : io.BytesIO
        The file buffer to decrypt
    key : bytes
        The secret key for AES decryption
    signature : bytes
        Additional data used to verify the key
    iv : bytes
        The initialization vector from the EncryptionIterator object
    tag : bytes
        The tag used for data integrity from the EncryptionIterator object
    chunk_size : int
        How much data to decrypt per iteration
    """
```

