Утилита декордирования
Some checks failed
CI / backend (push) Failing after 12s
CI / frontend (push) Failing after 4s

This commit is contained in:
2025-12-01 11:52:57 +00:00
parent 68649ba214
commit 4a75e30671

View File

@@ -1,7 +1,9 @@
from typing import Dict
# Таблица Base64-подобного варианта
VariantBase64Table: str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
VariantBase64Table: str = (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
)
VariantBase64Dict: Dict[int, str] = {
i: VariantBase64Table[i] for i in range(len(VariantBase64Table))
}
@@ -28,7 +30,8 @@ def variant_base64_encode(bs: bytes) -> bytes:
b: bytes = bs[3*i:3*i+3]
coding_int: int = int.from_bytes(b, "little")
block: str = "".join(
VariantBase64Dict[(coding_int >> shift) & 0x3F] for shift in (0, 6, 12, 18)
VariantBase64Dict[(coding_int >> shift) & 0x3F]
for shift in (0, 6, 12, 18)
)
result.extend(block.encode("ascii"))