This commit is contained in:
lapatatadouce
2025-07-15 22:54:17 +02:00
parent 588d901ca7
commit ba86c1be05
7 changed files with 128 additions and 158 deletions

View File

@@ -1,6 +1,7 @@
"""A collection of general utilities, not specific to any module."""
from crypt import crypt, METHOD_SHA512
import hashlib
import secrets
from getpass import getpass
from os import remove, rename
from pathlib import Path
@@ -36,8 +37,13 @@ def hash_user_password(printer=None):
p.failure("Passwords did not match")
return
# Generate a salt and create SHA-512 hash
salt = secrets.token_hex(16)
password_hash = hashlib.sha512((salt + password).encode()).hexdigest()
full_hash = f"$6${salt}${password_hash}"
p.info("Password hash:")
p.info(crypt(password, METHOD_SHA512))
p.info(full_hash)
def assert_system_dependencies_installed():
"""Checks whether all system dependencies required by udib are installed.