hashlib
Secure hash functions: SHA-256, SHA-3, BLAKE2 and more.
Easy
import hashlib
hashlib.sha256(b"firmware").hexdigest()
h = hashlib.sha256()
for chunk in iter(lambda: f.read(65536), b""): h.update(chunk) # hash a big file
For passwords use hashlib.scrypt or a library like argon2-cffi, never plain SHA.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.