Buckets:

download
raw
1.06 kB
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import json
from typing import TYPE_CHECKING
from cryptography.fernet import Fernet
if TYPE_CHECKING:
from syncmaster.scheduler.settings import SchedulerAppSettings
from syncmaster.server.settings import ServerAppSettings
from syncmaster.worker.settings import WorkerAppSettings
def decrypt_auth_data(
value: str,
settings: WorkerAppSettings | SchedulerAppSettings | ServerAppSettings,
) -> dict:
decryptor = Fernet(settings.encryption.secret_key)
decrypted = decryptor.decrypt(value)
return json.loads(decrypted)
def encrypt_auth_data(
value: dict,
settings: WorkerAppSettings | SchedulerAppSettings | ServerAppSettings,
) -> str:
encryptor = Fernet(settings.encryption.secret_key)
serialized = json.dumps(
value,
ensure_ascii=False,
sort_keys=True,
)
encrypted = encryptor.encrypt(serialized.encode("utf-8"))
return encrypted.decode("utf-8")

Xet Storage Details

Size:
1.06 kB
·
Xet hash:
41d640209bc2f497b0f4f2b8c0efe7c9e3ea0802270f9ef8da512984326c8c72

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.