18 lines
382 B
Python
18 lines
382 B
Python
"""Definition of hash_password function."""
|
|
|
|
import bcrypt
|
|
|
|
|
|
def hash_password(password: str) -> str:
|
|
"""Hash a password using bcrypt.
|
|
|
|
Args:
|
|
password: Plain text password to hash
|
|
|
|
Returns:
|
|
Hashed password as a string
|
|
"""
|
|
salt = bcrypt.gensalt()
|
|
hashed: bytes = bcrypt.hashpw(password.encode("utf-8"), salt)
|
|
return hashed.decode("utf-8")
|