MD5 vs SHA1 vs SHA256: Which Hash Should You Use? (With Live Examples)
MD5 vs SHA1 vs SHA256: Which Hash Should You Use? Hash functions are everywhere in software — file checksums, JWT signatures, API authentication, password storage. But picking the wrong one can be ...

Source: DEV Community
MD5 vs SHA1 vs SHA256: Which Hash Should You Use? Hash functions are everywhere in software — file checksums, JWT signatures, API authentication, password storage. But picking the wrong one can be a serious security mistake. Quick tool: Hash Generator Online — generate MD5, SHA1, SHA256, SHA512 in your browser (free, private). TL;DR — The Decision Table Use case Algorithm Notes Password storage bcrypt / Argon2 Never use MD5/SHA Digital signatures SHA-256 NIST approved File integrity SHA-256 or MD5 MD5 ok for non-security uses JWT (HS256) SHA-256 Standard choice Git commits SHA-1 (→ SHA-256) Being migrated TLS certificates SHA-256 SHA-1 certs rejected HMAC SHA-256 or SHA-512 Both secure Understanding Hash Functions A cryptographic hash function takes arbitrary input and produces a fixed-length output: import hashlib text = "Hello, World!" md5 = hashlib.md5(text.encode()).hexdigest() # 32 hex chars sha1 = hashlib.sha1(text.encode()).hexdigest() # 40 hex chars sha256 = hashlib.sha256(text