On this page
  1. hashlib.sha256
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

hashlib.sha256

Prev: hashlib.sha224 | Up: hashlib | Next: hashlib.sha384
Rel: hashlib.blake2b, hashlib.blake2s, hashlib.file_digest, hashlib.md5
Ref: docs.python.org — hashlib.sha256
Tags: #public #python3 #stdlib #hashlib


Import

import hashlib
from hashlib import sha256

Signature & Overview

hashlib.sha256(data=b'', *, usedforsecurity=True, string=None)

Returns a sha256 hash object; optionally initialized with a string

Usage

import hashlib

h = hashlib.sha256()
h.update(b"hello ")
h.update(b"world")
assert h.hexdigest() == hashlib.sha256(b"hello world").hexdigest()
assert len(h.digest()) == 32

Gotchas

REPL Inspect

from hashlib import sha256
help(sha256)

Linked from

Related notes