Files
MrBlakeandClaude Opus 5.5 b8f93fc11c feat(i18n): make UI translatable and add German translation
Wraps all user-visible strings (navigation, model fields, template, job and validation messages) in gettext and ships a German catalogue. A test keeps the documented NetBox range in line with min_version/max_version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 21:23:52 +01:00

27 lines
739 B
Python

import base64
import hashlib
from cryptography.fernet import Fernet, InvalidToken
from django.conf import settings
from django.utils.translation import gettext as _
def _fernet():
key = hashlib.sha256(settings.SECRET_KEY.encode("utf-8")).digest()
return Fernet(base64.urlsafe_b64encode(key))
def encrypt_secret(value):
if value in (None, ""):
return ""
return _fernet().encrypt(value.encode("utf-8")).decode("ascii")
def decrypt_secret(value):
if not value:
return ""
try:
return _fernet().decrypt(value.encode("ascii")).decode("utf-8")
except InvalidToken as exc:
raise ValueError(_("Stored endpoint password cannot be decrypted. Re-enter it on the endpoint.")) from exc