FastAPI + HTMX Web-App zum Speichern von Links mit automatischer KI-Kategorisierung, Zusammenfassung und semantischer Suche (OpenAI). Mehrbenutzer mit Login, SQLite-Persistenz, Docker/Docker-Compose-Setup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
16 lines
438 B
Python
16 lines
438 B
Python
import bcrypt
|
|
|
|
|
|
def hash_password(password: str) -> str:
|
|
# bcrypt akzeptiert max. 72 Bytes.
|
|
pw = password.encode("utf-8")[:72]
|
|
return bcrypt.hashpw(pw, bcrypt.gensalt()).decode("utf-8")
|
|
|
|
|
|
def verify_password(password: str, password_hash: str) -> bool:
|
|
try:
|
|
pw = password.encode("utf-8")[:72]
|
|
return bcrypt.checkpw(pw, password_hash.encode("utf-8"))
|
|
except (ValueError, TypeError):
|
|
return False
|