easy +8 pts

Password Salt Hash

Securely hash passwords with unique salts using SHA-256.

Implement the function `hash_password(password: str, salt: str) -> str` that returns a SHA-256 hex digest (lowercase, 64 characters) of the combined string `password + salt`. The salt is a random value appended directly to the password before hashing. This simple one-round approach is for educational purposes only — real systems should use stronger KDFs like PBKDF2 or bcrypt. Your function must return the hex digest exactly as computed by `hashlib.sha256((password + salt).encode('utf-8')).hexdigest()`.

Constraints

`password` and `salt` are strings containing only ASCII printable characters (no newlines). Length of each input is between 0 and 1000 characters. The output is always a 64-character lowercase hexadecimal string.

Example

>>> hash_password("hello", "world")
'936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af'
>>> hash_password("", "abc")
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
8 points ~12 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Concatenate the password and salt in that exact order.
Encode the combined string to bytes using UTF-8 before hashing.
Use `hashlib.sha256(...).hexdigest()` to get the result.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.