skylanix
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user