# 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
    decrypt : callable[bytes -> bytes]

    Notes
    -----
    Since NoEncryption will always succeed, it is only supported as the last
    entry in ``cryptos``.  Passing a list with a NoEncryption not in the last
    location will raise a ValueError.
    """
    __slots__ = ('_cryptos',)

    def __init__(self, cryptos):
        # Only the last crypto can be a ``NoEncryption``.
        for c in cryptos[:-1]:
            if isinstance(c, NoEncryption):
                raise ValueError(
                    "NoEncryption is only supported as the last fallback."
                )

        self._cryptos = cryptos

    def encrypt(self, s):
        return self._cryptos[0].encrypt(s)

    def decrypt(self, s):
        errors = []
        for c in self._cryptos:
            try:
                return c.decrypt(s)
            except CorruptedFile as e:
                errors.append(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

    decrypt : callable[bytes -> bytes]

    Notes
    -----
    Since NoEncryption will always succeed, it is only supported as the last
    entry in ``cryptos``.  Passing a list with a NoEncryption not in the last
    location will raise a ValueError.
    """
    __slots__ = ('_cryptos',)

    def __init__(self, cryptos):
        # Only the last crypto can be a ``NoEncryption``.
        for c in cryptos[:-1]:
            if isinstance(c, NoEncryption):
                raise ValueError(
                    "NoEncryption is only supported as the last fallback."
                )

        self._cryptos = cryptos

    def encrypt(self, s):
        return self._cryptos[0].encrypt(s)

    def decrypt(self, s):
        errors = []
        for c in self._cryptos:
            try:
                return c.decrypt(s)
            except CorruptedFile as e:
                errors.append(e)

        raise CorruptedFile(errors)