Glossary

Hash function

A hash function turns any data into a short value of fixed length, a kind of digital fingerprint that makes changes to the data easy to detect.

What is a hash function?

A hash function turns data of any size, such as a single word or an entire file, into a value of fixed length, called the hash. The same input always produces the same hash, while even a tiny change leads to a completely different one. Cryptographic hash functions such as SHA-256 or SHA-3 are also one-way functions: in practice, the input cannot be calculated back from the hash.

What hash functions are used for

Hashes let you check whether a downloaded file is unchanged: you compare the checksum published by the provider with the one you calculate yourself. Digital signatures usually sign the hash of a document rather than its entire content. Blockchains and many encryption methods are also built on hash functions. Older algorithms such as MD5 and SHA-1 are considered outdated for security purposes.

Hash functions and passwords

Reputable services do not store passwords in plain text, only as hashes. When you sign in, the password you enter is hashed again and compared with the stored value. Deliberately slow methods such as Argon2, bcrypt or scrypt are suited for passwords. A random extra value per password, known as a salt, ensures that identical passwords produce different hashes. Short passwords still remain easier to guess.

Frequently asked questions

Is hashing the same as encryption?

No. Encrypted data can be made readable again with the right key. A hash, by contrast, cannot be reversed; you can only check whether a particular input leads to the same value.

Can attackers recover a password from a stolen hash?

They cannot calculate it back, but they can try out candidates and compare their hashes. Long, random passwords that are used only once make this extremely time-consuming.

Do hash functions play a role in post-quantum cryptography?

Yes. Well-chosen hash functions are considered comparatively robust against quantum computers as well. The standardized post-quantum signature scheme SLH-DSA bases its security solely on the properties of hash functions.

Related terms

Related topics

Try Friendstime

Signing up takes a minute and is free.

All terms in the glossary →