# Path: pgcontents/error.py
# class CorruptedFile(Exception):
#     pass


import sys
import base64
from functools import wraps
from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from .error import CorruptedFile
    ----------
    fernet : cryptography.fernet.Fernet
       The Fernet object to use for encryption.

    Methods
    -------
    encrypt : callable[bytes -> bytes]
    decrypt : callable[bytes -> bytes]

    Notes
    -----
    ``cryptography.fernet.MultiFernet`` can be used instead of a vanilla
    ``Fernet`` to allow zero-downtime key rotation.

    See Also
    --------
    :func:`pgcontents.utils.sync.reencrypt_user`
    """
    __slots__ = ('_fernet',)

    def __init__(self, fernet):
        self._fernet = fernet

    def encrypt(self, s):
        return self._fernet.encrypt(s)

    def decrypt(self, s):
        try:
            return self._fernet.decrypt(s)
        except Exception as e:

# Path: pgcontents/error.py
# class CorruptedFile(Exception):
#     pass


# Path: pgcontents/crypto.py
import sys
import base64
from functools import wraps
from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from .error import CorruptedFile

    ----------
    fernet : cryptography.fernet.Fernet
       The Fernet object to use for encryption.

    Methods
    -------
    encrypt : callable[bytes -> bytes]
    decrypt : callable[bytes -> bytes]

    Notes
    -----
    ``cryptography.fernet.MultiFernet`` can be used instead of a vanilla
    ``Fernet`` to allow zero-downtime key rotation.

    See Also
    --------
    :func:`pgcontents.utils.sync.reencrypt_user`
    """
    __slots__ = ('_fernet',)

    def __init__(self, fernet):
        self._fernet = fernet

    def encrypt(self, s):
        return self._fernet.encrypt(s)

    def decrypt(self, s):
        try:
            return self._fernet.decrypt(s)
        except Exception as e:

            raise CorruptedFile(e)