Python Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-384, SHA-512 hashes online — with Python hashlib examples and tips.
🔒 100% private — runs entirely in your browserGenerate MD5, SHA-1, SHA-256, SHA-384, SHA-512 hashes online — with Python hashlib examples and tips.
🔒 100% private — runs entirely in your browserPython's hashlib module provides a common interface for many secure hash algorithms including MD5, SHA-1, SHA-256, SHA-384, and SHA-512. It's part of the standard library — no pip install required.
update() to hash files of any size without loading them into memory.import hashlib text = "Hello, World!"
hash_md5 = hashlib.md5(text.encode("utf-8")).hexdigest()
print(hash_md5) # 65a8e27d8879283831b664bd8b7f0ad4import hashlib text = "Hello, World!"
hash_sha256 = hashlib.sha256(text.encode("utf-8")).hexdigest()
print(hash_sha256) # dffd6021bb2bd5b0af676290809ec3a5...import hashlib def hash_file(filepath, algorithm="sha256"): h = hashlib.new(algorithm) with open(filepath, "rb") as f: for chunk in iter(lambda: f.read(8192), b""): h.update(chunk) return h.hexdigest() print(hash_file("myfile.zip"))import hmac
import hashlib secret = b"my-secret-key"
message = b"important data" signature = hmac.new(secret, message, hashlib.sha256).hexdigest()
print(signature) # keyed hash for message authenticationJust like Base64, hashlib functions expect bytes. Always call .encode('utf-8') on your string: hashlib.sha256(text.encode('utf-8')).
MD5 is cryptographically broken — collisions can be generated in seconds. Use bcrypt, argon2, or hashlib.pbkdf2_hmac() for password hashing. MD5 is still fine for checksums and non-security use cases.
.hexdigest() returns a hex string (e.g., '65a8e27d...'). .digest() returns raw bytes. Use hexdigest() for display and comparison; use digest() when feeding into another cryptographic operation.
When verifying hashes, use hmac.compare_digest(a, b) instead of ==. The == operator is vulnerable to timing attacks that can leak the expected hash value byte by byte.
Use hashlib.md5(string.encode('utf-8')).hexdigest(). This encodes the string to bytes, computes the MD5 hash, and returns the 32-character hexadecimal digest.
MD5 produces a 128-bit (32 hex chars) hash and is fast but cryptographically broken — collisions exist. SHA-256 produces a 256-bit (64 hex chars) hash and remains secure for cryptographic use. Use SHA-256 for security; MD5 is fine for checksums.
Open the file in binary mode and read in chunks: create a hasher with hashlib.sha256(), loop with f.read(8192), call h.update(chunk), then h.hexdigest(). This handles files of any size without loading them fully into memory.
Don't use MD5 or SHA-256 directly for passwords. Use bcrypt, argon2-cffi, or hashlib.pbkdf2_hmac('sha256', password, salt, iterations) which adds salt and key stretching to resist brute-force attacks.
Yes. All hashing happens entirely in your browser using client-side JavaScript and the Web Crypto API. Your data is never sent to any server.