Skip to content

Commit ee5b1bf

Browse files
committed
Added doctest to sha256 function in merkle tree
1 parent 244d2de commit ee5b1bf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

blockchain/merkle_tree.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
1515

1616

1717
def sha256(data: str) -> str:
18-
"""Compute SHA-256 hash of a string."""
18+
"""
19+
Compute the SHA-256 hash of the given string.
20+
21+
Args:
22+
data (str): Input string.
23+
24+
Returns:
25+
str: Hexadecimal SHA-256 hash of the input.
26+
27+
Example:
28+
>>> sha256("abc")
29+
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
30+
"""
1931
return hashlib.sha256(data.encode()).hexdigest()
2032

2133

0 commit comments

Comments
 (0)