ข้ามไปยังเนื้อหาหลัก

Exness คืน 100% ของค่าคอมมิชชั่น IB

ไม่มีการหักใด ๆ ก่อนเงินถึงบัญชีของคุณ

EA และอินดิเคเตอร์ฟรี

XM คืน 90% ฝากขั้นต่ำ $5

What is hashing?

Hashing feeds data into a hash function, which returns a short code of fixed length called a hash. The same input always gives the same hash, a tiny change gives a completely different one, and there is no practical way to work back from the hash to the input. Bitcoin uses SHA-256 hashes to link blocks and name transactions.

เนื้อหานี้ยังมีเฉพาะภาษาอังกฤษ

อ่าน 5 นาทีAutoFXRebate

Type hello into a SHA-256 calculator and you get 64 characters starting with 2cf24dba. Type Hello, with a capital H, and the result starts with 185f8db3. One letter changed, and nothing in the result looks related.

That scrambled result is a hash. Hashes let a blockchain prove that its old records have not been edited, so they sit underneath almost everything else in this course.

What a hash function does

A hash function takes any input, such as a word or a whole book, and turns it into a short code of fixed length. That code is the hash, also called a digest.

A hash works like a fingerprint for data. It points to one exact piece of data without containing it, so you cannot rebuild a book from its hash any more than you can rebuild a person from a fingerprint.

Bitcoin's main hash function is SHA-256, short for Secure Hash Algorithm with a 256-bit output. Ethereum uses a different one called Keccak-256. Both do the same kind of job.

What a hash looks like

SHA-256 always returns 256 bits, the 1s and 0s computers work in. People usually write them in hexadecimal, which uses the digits 0 to 9 and the letters a to f.

Each hexadecimal character stands for 4 bits, so 256 bits become 64 characters. The length never changes: a single letter, a short word and a full sentence all come out as exactly 64 characters, and so would a 500-page book.

Three inputs, the letter a, the word hello and a 43-character sentence, pass through SHA-256 and each comes out as a 64-character hash, shown shortened.
Any input, short or long, gives a hash of the same 64-character length.

Here are real SHA-256 results. Each hash is cut to its first 16 characters so it fits on a phone screen.

InputSHA-256, first 16 of 64 characters
aca978112ca1bbdca
hello2cf24dba5fb0a30e
Hello185f8db32271fe25
hello.1589999b0ca6ef88
The quick brown fox jumps over the lazy dogd7a8fbb307d78094

You can check any of these in a free online SHA-256 tool. Type the input exactly, with no space at the end, because a trailing space makes a different input with a different hash.

The rules a good hash follows

A hash function is only useful in crypto if it keeps these promises:

  • The same input gives the same hash every time, on any computer.
  • The output has the same length whatever the size of the input.
  • It is quick to compute.
  • It only runs one way: there is no shortcut from a hash back to its input.
  • A tiny change in the input changes about half the bits of the hash. This is the avalanche effect.
  • In practice, nobody can find two different inputs that give the same hash.

The hello and Hello pair shows the avalanche effect at work. Inside the computer, lowercase h and capital H differ by a single bit. Of the 256 bits in the two hashes, 125 are different.

The inputs hello and Hello differ by one bit, while their SHA-256 hashes differ in 125 of 256 bits.
One bit changed in the input flips roughly half the bits of the hash.

That property protects you. If similar inputs gave similar hashes, an attacker could make small edits to a message and steer its hash toward one they wanted.

Worked example: why a simple hash fails

Here is a toy hash, for illustration only. Give each letter its place in the alphabet (A is 1, B is 2, up to Z at 26), add the numbers up, and keep the last two digits.

  1. CAT gives 3 + 1 + 20 = 24.
  2. ACT gives 1 + 3 + 20 = 24.
  3. Two different words share the hash 24.
A toy hash adds letter positions, so CAT and ACT both come out as 24, a collision.
A hash that ignores letter order lets two different inputs share one output.

Two inputs with the same hash are a collision. The toy hash ignores the order of the letters, so collisions are easy to make. Someone could rearrange a message and keep the same hash.

Real hash functions mix every bit with its position, over and over. SHA-256 has 2 to the power of 256 possible outputs, a number 78 digits long.

As of 2026, no one has published two inputs that share a SHA-256 hash. Researchers have found collisions only in cut-down versions that run about half of its 64 rounds.

Older functions did not hold up as well. Researchers found ways to make collisions for MD5 and SHA-1, and security software stopped trusting them for that reason.

Hashing is different from encryption

Encryption scrambles data so that someone with the right key can turn it back. Hashing has no key and no way back. Once data is hashed, the hash alone will never give you the original.

This is why a well-run website stores a hash of your password rather than the password itself. When you log in, the site hashes what you typed and compares the two hashes.

The one-way rule has a limit, though. Anyone can guess an input, hash it and compare. A short or common password falls to this quickly, which is why length matters so much.

Where hashes appear in crypto

You will meet hashes in almost every part of a blockchain:

  • Each block stores the hash of the block before it, which chains the blocks of a blockchain together. Editing an old block would break every link after it.
  • Each Bitcoin transaction is named by a hash of its contents, called the transaction ID.
  • Common Bitcoin address types are built by hashing a public key.
  • Mining is a race to find a block whose hash falls below a target number.

The next lesson, how hashing works, opens up the function and follows each of these uses in more detail.

คำถามที่พบบ่อย

Can a hash be reversed?

Not for a secure function like SHA-256. The only route is to guess inputs, hash each one and compare, which works only when the input is short or predictable, such as a weak password.

What is a hash collision?

It is two different inputs that produce the same hash. Collisions must exist in theory, because inputs are unlimited and hashes have a fixed length, but a secure function makes them impossible to find in practice.

Why is a SHA-256 hash always 64 characters long?

SHA-256 always produces 256 bits, and one hexadecimal character holds 4 bits. 256 divided by 4 is 64.

Is SHA-256 the only hash function in crypto?

No. Bitcoin also uses RIPEMD-160 when it builds some address types, Ethereum uses Keccak-256, and other projects choose their own.

เรียนต่อ

บทที่ 3How does hashing work, and what is it used for?A hash function pads its input, cuts it into blocks of equal size and mixes each block into a running state over many rounds of bit operations. The final state is the hash. Crypto uses this to check files, store passwords, chain blocks together, summarise transactions in a Merkle root, build addresses and set the puzzle that miners solve.บทที่ 3What is encryption?Encryption turns readable data into scrambled text using a key, and the right key turns it back. Symmetric encryption uses one shared key, while public key encryption uses a matched pair. Unlike hashing, encryption can be reversed. Bitcoin's ledger is not encrypted at all: encryption protects your connection to an exchange and the wallet files that hold your keys.บทที่ 3Public and private keys explained.A private key is a large random number that only you should know, and it signs your transactions. A public key is calculated from the private key and can be shared freely, so others can check your signatures and send you coins. The calculation only runs one way, so a public key never reveals the private key behind it.บทที่ 3How do digital signatures work?A digital signature is a number calculated from a message and a private key. Anyone with the matching public key can check it. If the check passes, the message came from whoever holds the private key and has not changed by a single bit. Bitcoin nodes run this check on every transaction before they accept it.บทที่ 3How does a Bitcoin transaction work?A Bitcoin transaction spends earlier unspent outputs as its inputs, proves you may spend them with a signature, and creates new outputs: one for the person you pay and usually one returning change to you. Whatever the inputs hold beyond the outputs is the fee. Nodes check the transaction, and a miner adds it to a block.
ความคิดเห็น

บัญชีของคุณอยู่กับโบรกเกอร์ไหน?

แต่ละโบรกเกอร์มีขั้นตอนไม่เหมือนกัน เราจึงจะพาคุณไปยังชุดขั้นตอนที่ถูกต้องโดยตรง