Next

Salted SHA-256 password hash

Write codeEasy12 min

Your task

Compute a salted SHA-256 digest for password storage. Given a password and a salt (both strings), return the lowercase hex SHA-256 digest of the salt concatenated BEFORE the password (i.e. hash of salt + password), both UTF-8 encoded. Return the 64-character hex string.

Examples

salted_digest(password: str, salt: str) -> str
Example 1
Inputsalted_digest("pass", "s4lt")
Output"e3b5bc3bd05bb8579aa0695bd9606fd5fb7a12fea904bb09fb2ecea441f2c067"