A hash function is a mathematical algorithm that transforms input data of any size into a fixed-size string of characters. The output, called a hash or digest, is unique to the input data - even a small change in input produces a completely different hash.
Hash functions are one-way operations, meaning you cannot reverse the process to get the original input from the hash. This makes them perfect for data integrity verification and password storage.
Algorithm | Output Size | Security | Use Case |
---|---|---|---|
MD5 | 128-bit (32 hex) | Broken | Checksums only |
SHA-1 | 160-bit (40 hex) | Deprecated | Legacy systems |
SHA-256 | 256-bit (64 hex) | Secure | Recommended |
SHA-512 | 512-bit (128 hex) | Very Secure | High security |
MD5 and SHA-1 are cryptographically broken and should not be used for security purposes. Use SHA-256 or SHA-512 for new applications requiring cryptographic security.