A file hash is a unique digital fingerprint of a file, generated by applying a mathematical algorithm to the file's contents. Even a tiny change to the file will produce a completely different hash value.
Hashes are commonly used to verify file integrity, ensure files haven't been tampered with, and confirm successful downloads. Different hash algorithms provide varying levels of security and performance:
Standard Hash Algorithms
- MD5 (128-bit): Fast but less secure. Widely used for checksums but vulnerable to collision attacks. Not recommended for security-critical applications.
- SHA-1 (160-bit): Legacy algorithm, no longer considered secure for cryptographic purposes. Still used for non-security critical applications.
- SHA-256 (256-bit): Part of the SHA-2 family, provides good security. Widely used in security applications, digital signatures, and blockchain technology.
- SHA-384 (384-bit): A truncated version of SHA-512 with a different initial value. Offers a good balance between security and performance.
- SHA-512 (512-bit): Provides stronger security with larger output. Suitable for security-critical applications where maximum security is required.
SHA-3 Family
- SHA3-224 (224-bit): The newest member of the Secure Hash Algorithm family with 224-bit output.
- SHA3-256 (256-bit): SHA-3 variant with 256-bit output, designed to be more resistant to attacks than SHA-2.
- SHA3-384 (384-bit): SHA-3 variant with 384-bit output for applications requiring higher security.
- SHA3-512 (512-bit): SHA-3 variant with 512-bit output, offering maximum security in the SHA-3 family.
Other Hash Algorithms
- RIPEMD-160 (160-bit): European alternative to SHA-1, designed for improved security and performance.
Keyed Hash Functions (HMAC)
- HMAC-MD5: Keyed-hash message authentication code using MD5. Adds a secret key to the hash for authentication.
- HMAC-SHA1: HMAC using SHA-1. More secure than HMAC-MD5 but less secure than newer HMAC variants.
- HMAC-SHA256: HMAC using SHA-256. Provides good security for message authentication.
- HMAC-SHA384: HMAC using SHA-384. Higher security than HMAC-SHA256.
- HMAC-SHA512: HMAC using SHA-512. Maximum security for message authentication.
Key Derivation
- PBKDF2 (Password-Based Key Derivation Function 2): Applies a pseudorandom function to the input along with a salt value and repeats the process many times to produce a derived key. Used for password hashing and key generation.
When verifying file integrity, it's recommended to use at least SHA-256 or stronger algorithms. For password hashing, PBKDF2 or other specialized password hashing functions should be used instead of simple hash functions.