Funktionstrennung 1.0

This commit is contained in:
Nirodan
2025-06-17 11:28:06 +02:00
parent 97acda1d2b
commit 8ca650cf11
11 changed files with 199 additions and 48 deletions
+1
View File
@@ -0,0 +1 @@
from .md5 import md5_blueprint
+32
View File
@@ -0,0 +1,32 @@
from flask import Blueprint, request, jsonify
import hashlib
from util.logger import logger
from auth.token import verify_token
md5_blueprint = Blueprint('md5_tool', __name__)
@md5_blueprint.route('/api/hash/md5', methods=['POST'])
def hash_md5():
logger.info("🔁 /api/hash/md5 aufgerufen")
user = verify_token()
if not user:
logger.warning("⛔ Nicht autorisiert")
return jsonify({"message": "Nicht autorisiert"}), 401
try:
data = request.get_json()
logger.debug(f"📩 Payload: {data}")
password = data.get("password", "")
result = hashlib.md5(password.encode()).hexdigest()
logger.info(f"✅ Hash erstellt von {user['username']}")
return jsonify({
"md5": result,
"by": user['username']
})
except Exception as e:
logger.error(f"❌ Fehler beim Hashen: {e}")
return jsonify({"message": "Fehler beim Hashen"}), 500