Hashing
Hashing is a mathematical process of converting any amount of input data into a unique string of characters of fixed length (a hash sum). It is an irreversible operation used for fast data identification, verifying their integrity and secure storage of passwords.
Contents
What is hashing in simple words
Hashing is the process of converting any data (text, file, password) into a unique string of characters of fixed length — a hash. It is like a digital fingerprint: each set of data has its own unique hash, and by it you can instantly check whether the file has changed.
An important property of hashing is irreversibility. It is impossible to restore the original data from a hash. This is as if you mixed paints: you can never get the original colors back. That is why hashing is ideal for storing passwords.
Read about encryption and its difference from hashing in the article Data encryption.
How hashing works
- Input data: Any amount of information — from one character to a gigabyte file.
- Hash function (algorithm): A mathematical formula that converts data into a string of fixed length (for example, 256 bits for SHA-256).
- Output data (hash): A unique string of characters. Even a minimal change in the input data completely changes the hash — this is called the “avalanche effect”.
Example: the word “Hello” and “hello” (different case) will give completely different hashes.
Where hashing is used
- Password storage: Websites do not store your passwords in open form. They save only the hash. When logging in, the system hashes the entered password and compares it with the one in the database. Even if the database is stolen, hackers will not learn your passwords.
- File integrity verification: By downloading a program or disk image, you can verify its hash sum with the one stated on the official website. If they match — the file is not damaged and has not been changed.
- Digital signatures: Hashing is used to create a “digest” of a message before signing it.
- Blockchain and cryptocurrencies: Each block in the blockchain contains the hash of the previous block, which ensures the immutability of the entire chain.
Read about the blockchain in the article Blockchain.
Popular hashing algorithms
- MD5: An outdated algorithm that produces a 128-bit hash. Today it is considered insecure due to collisions (matching hashes for different data).
- SHA-1: Produces a 160-bit hash. Also outdated and not recommended for use.
- SHA-256 (SHA-2): Produces a 256-bit hash. The main standard for most security systems and cryptocurrencies (including Bitcoin).
- SHA-3: An improved and even more secure version.
- Argon2 / bcrypt: Specialized algorithms for hashing passwords. Slow and resource-intensive — this is a plus, as it complicates password guessing.
What is a hash collision
A collision is a situation when two different sets of data produce the same hash. A good hash function must minimize the probability of collisions. In old algorithms (MD5, SHA-1) collisions were found, so they are considered insecure. Modern algorithms (SHA-256, SHA-3) practically exclude collisions.
Read about data security in the article Information security.
How hashing differs from encryption
- Reversibility: Encryption is reversible (it can be decrypted with a key), hashing is irreversible.
- Presence of a key: A key is needed for encryption, but not for hashing.
- Size of the result: A hash is always of fixed length, ciphertext depends on the amount of data.
- Purpose: Encryption — to hide data, hashing — to verify integrity.
Read about encryption in the article Data encryption.
Frequently asked questions
What is hashing in simple words?
Hashing is the conversion of data into a unique string of fixed length (a hash). It is like a digital fingerprint: even a minimal change in the data completely changes the hash. It is impossible to restore the data from the hash back. Read about encryption in the article Data encryption.
What is the difference between encryption and hashing?
Encryption is reversible — data can be decrypted with a key. Hashing is irreversible — the original data cannot be restored from a hash. Encryption hides data, hashing verifies integrity. A key is needed for encryption, but not for hashing. Read about encryption in the article Data encryption.
Which hashing algorithm is the most secure?
For general purposes — SHA-256 and SHA-3. For storing passwords — bcrypt, Argon2 or scrypt. They are specially slow, which protects against password guessing. MD5 and SHA-1 are considered outdated and insecure. Read about security in the article Information security.
Why is hashing needed in the blockchain?
In the blockchain, each block contains the hash of the previous block. This links the blocks into a chain and makes the system immutable — if you change one block, all subsequent hashes will change, and the network will notice the forgery. Hashing is also used in mining. Read about the blockchain in the article Blockchain.
Why can't a hash be decrypted?
Hashing is not encryption; it has no key and no inverse function. We do not “hide” the data, but compress it to a fixed length, losing part of the information. Therefore, it is impossible to restore the original data from just one hash. Read about encryption in the article Data encryption.
Other terms in «Cryptocurrency and Blockchain»
Was this information helpful?
Need help with implementation?
Leave a request — our specialists will contact you and help solve the hashing task. Individual approach and guaranteed results.