Generate secure hash values for text or files using multiple algorithms including MD5, SHA-1, SHA-256, SHA-512, and more. A hash function takes input data of any length and produces a fixed-length output value, useful for data integrity verification, checksums, and digital signatures.
A cryptographic hash function is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash). It is designed to be a one-way function, that is, a function which is infeasible to invert.
Algorithm | Output Size | Security Level | Common Uses |
---|---|---|---|
MD5 | 128 bits (32 hex chars) | Low (vulnerable to collisions) | File checksums, non-security critical applications |
SHA-1 | 160 bits (40 hex chars) | Low (vulnerable to collisions) | Legacy systems, file verification |
SHA-256 | 256 bits (64 hex chars) | High | Digital signatures, blockchain, secure checksums |
SHA-512 | 512 bits (128 hex chars) | Very High | Critical applications requiring maximum security |
SHA3-256 | 256 bits (64 hex chars) | High | Modern applications requiring high security |
RIPEMD-160 | 160 bits (40 hex chars) | Medium | Bitcoin addresses, European projects |
Verify that files or messages haven't been altered during transmission by comparing hash values before and after.
Store password hashes instead of plaintext passwords, so even if a database is compromised, actual passwords remain secure.
Combine hash functions with asymmetric encryption to create secure digital signatures for documents.
Create secure, tamper-evident chains of transactions where each block contains the hash of the previous block.
// JavaScript (using Web Crypto API)
async function generateSHA256Hash(message) {
const encoder = new TextEncoder();
const data = encoder.encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
// Convert buffer to hex string
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}
// Use the function
generateSHA256Hash('Hello, world!').then(hash => {
console.log('SHA-256 hash:', hash);
});
// Python implementation
import hashlib
def generate_sha256_hash(message):
# Convert string to bytes if it isn't already
if isinstance(message, str):
message = message.encode('utf-8')
# Generate hash
hash_obj = hashlib.sha256(message)
return hash_obj.hexdigest()
# Use the function
message = "Hello, world!"
print(f"SHA-256 hash: {generate_sha256_hash(message)}")