hashlib.sha256()
hashlib.sha256() is a Python function in the Hashlib Module category. Creates a SHA-256 hash object — widely used for secure hashing. The syntax is hashlib.sha256(data=b""). Parameters: data — bytes input. Returns: Hash object. A typical example: h = hashlib.sha256(b"hello")
h.hexdigest() # "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824". A close sibling is hashlib.md5(), which creates an MD5 hash object for the given data. A close sibling is hashlib.sha1(), which creates a SHA-1 hash object (deprecated for security use). A close sibling is hashlib.sha512(), which creates a SHA-512 hash object with larger digest size (512 bits). A close sibling is hashlib.sha3_256(), which creates a SHA-3 (Keccak) 256-bit hash object. More about this category: Secure hash and message digest algorithms — MD5, SHA-1, SHA-256, BLAKE2. For a broader walkthrough, read the Hashlib Module guide. Related Hashlib Module entries: hashlib.md5(), hashlib.sha1(), hashlib.sha512(), hashlib.sha3_256(), hashlib.blake2b(), hashlib.pbkdf2_hmac(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.