Security and Identifier Modules

hashlib

Calculates message digests from bytes using algorithms such as SHA-256. A digest is not encryption and alone does not authenticate a message. Repeated update calls process successive chunks of the same input. Password storage requires a dedicated salted, cost-adjustable password hashing scheme rather than a single fast digest.

Formal Syntax & Structure

python syntaxpython
import hashlib

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import hashlibdigest = hashlib.sha256(b"abc")print(digest.hexdigest())
Python Reference