Developer

Generador de hash

Genere hashes criptográficos MD5, SHA-1, SHA-256 y SHA-512 a partir de cualquier texto en el navegador. Se ejecuta completamente en su navegador: no se envían datos a ningún servidor, no se requiere cuenta y es completamente gratis.

The Complete Guide to Cryptographic Hash Functions

Cryptographic hash functions are the silent workhorses of modern internet security. They protect your passwords in databases, verify the integrity of software downloads, power blockchain networks, and authenticate digital communications. Despite their fundamental importance, they are often poorly understood — and misused. This guide explains what hash functions are, how the most common algorithms (MD5, SHA-1, SHA-256, SHA-512) differ, and when to use each one.

What is a Cryptographic Hash Function?

A cryptographic hash function is a mathematical algorithm that takes an input of any size and produces a fixed-size output string called a hash, digest, or checksum. The key properties that make a function "cryptographic" are:

  • Deterministic: The same input always produces the exact same hash output. Hash("hello") will always equal the same 64-character string.
  • One-way (Pre-image Resistance): Given only the hash output, it is computationally infeasible to determine what the original input was. You cannot "reverse" a hash.
  • Avalanche Effect: A tiny change in the input produces a completely different, unpredictable hash. Changing a single character changes approximately 50% of the output bits.
  • Collision Resistance: It should be computationally infeasible to find two different inputs that produce the same hash output. (Note: some older algorithms like MD5 and SHA-1 have had collisions demonstrated.)
  • Fixed Output Length: Regardless of whether the input is 1 byte or 1 gigabyte, the output is always the same fixed length for a given algorithm.

Cryptographic Hash Algorithms Comparison Matrix

Algorithm Output Bits Hex Output Length Security Rating Recommended Use Cases
MD5 128 bits 32 chars Broken (Insecure) File integrity checksums, cache keys, database indexing. Never for security.
SHA-1 160 bits 40 chars Deprecated Legacy Git commits (transitioning to SHA-256), backward compatibility.
SHA-256 256 bits 64 chars Secure (Gold Standard) TLS/SSL certificates, Bitcoin & blockchain, HMAC APIs, software signing.
SHA-512 512 bits 128 chars Highly Secure High-entropy cryptographic verification, Unix shadow passwords, 64-bit systems.

Standard NIST Hash Test Vectors

To verify the accuracy of your hashing implementation or this online tool, you can compare against official NIST/RFC reference test vectors:

  • Input: "" (Empty string)
    • MD5: d41d8cd98f00b204e9800998ecf8427e
    • SHA-1: da39a3ee5e6b4b0d3255bfef95601890afd80709
    • SHA-256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
    • SHA-512: cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
  • Input: The quick brown fox jumps over the lazy dog
    • SHA-256: d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592

How to Generate Hashes in Code

Here is how you can compute SHA-256 cryptographic hashes in your favorite programming languages:

1. JavaScript / Node.js

const crypto = require('crypto');

function generateSHA256(text) { return crypto.createHash(‘sha256’).update(text, ‘utf8’).digest(‘hex’); }

console.log(generateSHA256(‘hello world’)); // b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

2. Python 3

import hashlib

def generate_sha256(text: str) -> str: return hashlib.sha256(text.encode(‘utf-8’)).hexdigest()

print(generate_sha256(“hello world”))

3. PHP 8+

<?php
$hash = hash('sha256', 'hello world');
echo $hash;
?>

4. Linux / macOS Terminal

echo -n "hello world" | sha256sum

Important: Hash Functions Are NOT for Password Storage

This is a critical distinction that trips up many developers. Raw cryptographic hash functions (SHA-256, SHA-512, MD5) should never be used directly to store user passwords in a database. Here's why:

SHA-256 and similar algorithms are designed to be fast. This is great for data integrity verification, but catastrophic for passwords. A modern GPU cluster can compute billions of SHA-256 hashes per second. An attacker who steals a database of unsalted or single-round SHA-256 hashes can run a massive dictionary attack and crack most passwords in hours.

For password storage, always use a slow, adaptive, salted hashing function specifically designed for authentication:

  • Bcrypt: The industry standard for web applications. Features an adjustable work factor (cost) that scales with computing power. Generate hashes with our Free Bcrypt Generator.
  • Argon2: Winner of the Password Hashing Competition. Highly resistant to GPU and ASIC cracking attacks.
  • scrypt: Memory-hard hashing algorithm that makes large-scale hardware parallel attacks cost-prohibitive.

For an in-depth technical analysis on hashing mechanics, read our complete guide on Understanding Cryptographic Hashes: MD5, SHA-1, SHA-256, and SHA-512.

Cómo utilizar el Generador de hash

  1. 1

    Enter text to hash

    Type or paste the text (password, file content, message, etc.) that you want to hash.

  2. 2

    Click Generate Hashes

    The tool simultaneously calculates MD5, SHA-1, SHA-256, and SHA-512 hashes.

  3. 3

    Copy any hash

    Click Copy next to the hash algorithm you need. Each hash is shown in lowercase hexadecimal format.

Preguntas Frecuentes

What is a cryptographic hash?

A hash function takes any input and produces a fixed-length string of characters. The same input always produces the same hash, but even a tiny change in input produces a completely different hash. Hashes are one-way — you cannot recover the original input from the hash.

What is SHA-256 used for?

SHA-256 is the gold standard for data integrity verification, file checksums, digital signatures, and blockchain (Bitcoin uses SHA-256). It is recommended over SHA-1 and MD5 for security-sensitive applications.

Is MD5 still secure?

MD5 is no longer considered cryptographically secure for security purposes — collisions have been demonstrated. However, it is still widely used for non-security checksums (e.g., verifying file downloads did not corrupt). Use SHA-256 for any security-sensitive hashing.

How is hashing done — is it on the server?

SHA-1, SHA-256, and SHA-512 are computed using the browser's built-in Web Crypto API (crypto.subtle.digest). MD5 uses the crypto-js library. All computation is local — nothing leaves your browser.

Can I hash a password with this tool?

This tool shows raw hashes which are NOT suitable for password storage. Password storage requires a slow, salted hashing algorithm like bcrypt, argon2, or scrypt. Use this tool for checksums and integrity verification, not password hashing.

Compartir:

From the Blog

Understanding Cryptographic Hashes: MD5, SHA-1, SHA-256, and SHA-512 Explained →

Deep dive into related concepts, tutorials, and best practices.