Web3 & DApp Development Fundamentals · Lección

Hashing en blockchain

Inmutabilidad mediante hashes

Lección 3 de 413 pasos

Hashing en blockchain es una lección gratuita de Web3 & DApp Development Fundamentals en CoddyKit. Esta es la lección 3 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Web3 & DApp Development Fundamentals, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Web3 & DApp Development Fundamentals incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

What Is a Hash Function?

A hash function takes any input and produces a fixed-size output called a digest or hash.

Blockchains rely on cryptographic hash functions like SHA-256 (Bitcoin) and Keccak-256 (Ethereum).

sha256("hello") =
  2cf24dba5fb0a30e26e83b2ac5b9e29e
  1b161e5c1fa7425e73043362938b9824

Deterministic Output

Hashing is deterministic: the same input always yields the same output.

This lets any node independently verify a hash and arrive at the identical result — essential for distributed agreement.

The Avalanche Effect

A tiny change in the input produces a completely different hash. This is the avalanche effect.

Notice how changing one letter changes the entire digest:

sha256("blockchain") -> ef7797e13d3a...
sha256("Blockchain") -> 3f1d8b9c2a04...
(totally different)

Fixed Output Size

No matter how large the input, the output is always the same length. SHA-256 always returns 256 bits (64 hex characters).

This makes hashes convenient, compact identifiers for blocks, transactions, and state.

Preimage Resistance

A good hash function is one-way: given a hash, you cannot feasibly find the input that produced it.

This preimage resistance is why hashes can safely commit to data without revealing it.

Collision Resistance

Collision resistance means it is infeasible to find two different inputs with the same hash.

If collisions were easy, an attacker could swap one block or transaction for another that shares the same hash — destroying the chain's integrity.

Hashes Create the Chain Link

Recall that each block stores the hash of the previous block. Because hashing is deterministic and collision-resistant, this link is secure.

Altering an old block changes its hash, breaking the chain at that point.

block.hash = keccak256(
    block.previousHash +
    block.merkleRoot +
    block.timestamp +
    block.nonce
)

Immutability Through Hashing

Immutability emerges from chained hashes. To change block 100, you must recompute block 100's hash, then 101, 102, and every block after it.

In a proof-of-work chain, that also means redoing all of their mining — practically impossible.

Hash Pointers

A hash pointer is a reference to data plus the hash of that data. If the data is tampered with, the stored hash no longer matches.

Blockchains are essentially linked lists built from hash pointers.

struct HashPointer {
    location: address-of-block
    hash:     expected-hash-of-block
}

Addresses and Hashing

Hashing also generates account addresses. An Ethereum address is derived by hashing the public key with Keccak-256 and keeping the last 20 bytes.

So hashing is woven through identity as well as integrity.

address = last20bytes(
    keccak256(publicKey)
)

Putting It Together

Cryptographic hashing gives blockchains their core guarantees: deterministic verification, tamper-evidence, compact identifiers, and immutability.

Every block link, Merkle root, and address depends on it.

Quick Check

Test your hashing knowledge.

Recap: Hashing in Blockchain

You learned that:

  • Hash functions are deterministic and produce fixed-size output
  • The avalanche effect means tiny changes alter the whole hash
  • Preimage and collision resistance secure the chain
  • Chained hashes create immutability

Next: how this data is shared across a distributed ledger.

Gratis para empezar

Aprende Web3 & DApp Development Fundamentals con un tutor de IA — gratis

Escribe y ejecuta código real en tu navegador, obtén ayuda instantánea de un tutor de IA disponible 24/7 y continúa donde lo dejaste en la web o en la aplicación.

Cursos
29
Lecciones
105

Preguntas frecuentes

¿La lección «Hashing en blockchain» es gratis?

Sí — el texto completo de «Hashing en blockchain» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Web3 & DApp Development Fundamentals, actualiza a CoddyKit PRO. El curso de Web3 & DApp Development Fundamentals incluye 4 lecciones en total.

¿Qué aprenderé en «Hashing en blockchain»?

Inmutabilidad mediante hashes Practicas Web3 & DApp Development Fundamentals con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Web3 & DApp Development Fundamentals?

No se requiere experiencia previa. Web3 & DApp Development Fundamentals en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 3 de 4.

¿Cuánto tiempo toma la lección «Hashing en blockchain»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Web3 & DApp Development Fundamentals?

Sí. Cada lección de Web3 & DApp Development Fundamentals incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Bloques y cadenas
  2. Árboles de Merkle
  3. Hashing en blockchain
  4. Libros mayores distribuidos
← Volver a Web3 & DApp Development Fundamentals