# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.

import typing
from collections.abc import Sequence

from cryptography.utils import Buffer

class Fernet:
    def __init__(
        self, key: bytes | str, backend: typing.Any = None
    ) -> None: ...
    @classmethod
    def generate_key(cls) -> bytes: ...
    def encrypt(self, data: Buffer) -> bytes: ...
    def encrypt_at_time(self, data: Buffer, current_time: int) -> bytes: ...
    def _encrypt_from_parts(
        self, data: Buffer, current_time: int, iv: Buffer
    ) -> bytes: ...
    def decrypt(self, token: bytes | str, ttl: int | None = None) -> bytes: ...
    def decrypt_at_time(
        self, token: bytes | str, ttl: int, current_time: int
    ) -> bytes: ...
    def extract_timestamp(self, token: bytes | str) -> int: ...
    @staticmethod
    def _get_unverified_token_data(
        token: bytes | str,
    ) -> tuple[int, bytes]: ...

class MultiFernet:
    def __init__(self, fernets: Sequence[Fernet]) -> None: ...
    def encrypt(self, msg: Buffer) -> bytes: ...
    def encrypt_at_time(self, msg: Buffer, current_time: int) -> bytes: ...
    def rotate(self, msg: bytes | str) -> bytes: ...
    def decrypt(self, msg: bytes | str, ttl: int | None = None) -> bytes: ...
    def decrypt_at_time(
        self, msg: bytes | str, ttl: int, current_time: int
    ) -> bytes: ...
    def extract_timestamp(self, msg: bytes | str) -> int: ...
