easy +5 pts

SHA256 Hash String

Compute the SHA256 hexadecimal digest of any text input.

Implement a function `sha256_hash(text: str) -> str` that takes a string `text` and returns its SHA256 hash as a hexadecimal string (lowercase, 64 characters). Use Python's `hashlib` module with the `sha256` algorithm. The input will always be a string; if it is empty, return the SHA256 hash of an empty string. The result must be a 64-character lowercase hexadecimal string.

Constraints

Input is any string (including empty). Output is always a 64-character lowercase hexadecimal string. Time complexity is O(n) where n is the length of the input.

Example

>>> sha256_hash('hello')
'2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
>>> sha256_hash('')
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
>>> sha256_hash('Python')
'18885f27b5af9012df19e496460f9294d5ab76128824c6f993787004f6d9a7db'
5 points ~5 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use `hashlib.sha256()` on the bytes of the string.
Encode the string with `utf-8` before hashing.
Call `.hexdigest()` to get the hex string.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.