19 lines
715 B
Python
19 lines
715 B
Python
|
|
import hashlib
|
||
|
|
import hmac
|
||
|
|
|
||
|
|
SECRET_PEPPER = b"yahtzee_tui_super_secret_pepper_2026"
|
||
|
|
|
||
|
|
class SecurityManager:
|
||
|
|
"""Verantwortlich für Passwort-Hashing und Manipulationsschutz (HMAC-Signaturen)."""
|
||
|
|
@staticmethod
|
||
|
|
def hash_password(password):
|
||
|
|
return hashlib.sha256((password + "salt").encode()).hexdigest()
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def generate_signature(stats_dict, pass_hash):
|
||
|
|
data_string = (
|
||
|
|
f"{stats_dict['vr_w']}{stats_dict['vr_l']}{stats_dict['vr_h']}"
|
||
|
|
f"{stats_dict['vb_w']}{stats_dict['vb_l']}{stats_dict['vb_h']}"
|
||
|
|
)
|
||
|
|
key = (pass_hash + SECRET_PEPPER.decode()).encode()
|
||
|
|
return hmac.new(key, data_string.encode(), hashlib.sha256).hexdigest()
|