Dateien nach "docs/Zierl" hochladen

This commit is contained in:
2026-02-09 11:37:32 +00:00
parent ebbbcdb8ff
commit 41570534fa
5 changed files with 629 additions and 0 deletions

21
docs/Zierl/Ziel_2.txt Normal file
View File

@@ -0,0 +1,21 @@
def make_signed_system_token(system_user_token: str, private_key_pem: str) -> str:
# 1) stamp in UTC like yyyyMMddHHmm
ts = datetime.now(timezone.utc).strftime("%Y%m%d%H%M")
to_sign = f"{system_user_token}.{ts}".encode("utf-8")
# 2) load your RSA private key (PEM, PKCS#1 or PKCS#8)
key = serialization.load_pem_private_key(
private_key_pem.encode("utf-8"), password=None
)
# 3) RSA-SHA256, PKCS#1 v1.5 padding, then Base64 (standard, not URL-safe)
signature = key.sign(to_sign, padding.PKCS1v15(), hashes.SHA256())
sig_b64 = base64.b64encode(signature).decode("ascii")
# 4) final SignedSystemToken
return f"{system_user_token}.{ts}.{sig_b64}"
# print(load_rsa_private_key_pem(PEM_STR)) # test loading key
print(make_signed_system_token(SYSTEM_USER_TOKEN, PEM_STR))