easy +10 pts

Compute SHA-1 Hash String

Implement a function that returns the SHA-1 hexadecimal digest of a given string.

Implement a function `sha1_hash_string(s: str) -> str` that returns the SHA-1 hash of the input string `s`, expressed as a 40-character lowercase hexadecimal string. Use Python's `hashlib` module. The input is a regular string (not bytes).

Constraints

Input length: 0 ≤ len(s) ≤ 10^6 Output is always a 40-character lowercase hexadecimal string.

Example

>>> sha1_hash_string("hello")
'f572d396fae9206628714fb2ce00f72e94f2258f'
>>> sha1_hash_string("")
'da39a3ee5e6b4b0d3255bfef95601890afd80709'
10 points ~15 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Remember to encode the string to bytes using `.encode()` before hashing.
Use `hashlib.sha1(...)` to create the hash object.
Call `.hexdigest()` on the hash object to get the hex string.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.