Files
Power BI Dev 9be6bd03e3 Gabungkan aplikasi RPS & Portofolio OBE (dashboard jadi bagian aplikasi)
Dashboard pemetaan statis kini dilayani aplikasi di /dashboard
(app/static/dashboard.html). Fitur lengkap Tahap 1-4 + dasbor monitoring,
menu global, filter semester, input nilai langsung, penggabungan nilai
team teaching, tabel bisa urut. Dockerfile berubah dari nginx statis ke
uvicorn/FastAPI: healthcheck, proxy-headers, volume /data (SQLite).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 12:05:28 +07:00

29 lines
803 B
Python

# -*- coding: utf-8 -*-
"""Autentikasi: hashing password (PBKDF2) & token sesi."""
import hashlib
import hmac
import secrets
_ITERASI = 200_000
def hash_password(password: str) -> str:
salt = secrets.token_hex(16)
h = hashlib.pbkdf2_hmac("sha256", password.encode("utf-8"),
bytes.fromhex(salt), _ITERASI)
return f"{salt}${h.hex()}"
def verifikasi_password(password: str, tersimpan: str) -> bool:
try:
salt, h = tersimpan.split("$", 1)
calon = hashlib.pbkdf2_hmac("sha256", password.encode("utf-8"),
bytes.fromhex(salt), _ITERASI)
return hmac.compare_digest(calon.hex(), h)
except (ValueError, TypeError):
return False
def token_baru() -> str:
return secrets.token_urlsafe(32)