What is Hash function?
A function that computes a value of fixed length (a hash value) from data of any length. Those used in cryptography, such as SHA-256, are built so that it is practically impossible either to find the original data from a hash value or to find two pieces of data with the same hash value, and they are used for detecting tampering, digital signatures and password storage.
Japanese name: ハッシュ関数
Hash function appears in 7 practice questions across 2 topics, including Information Security Basics, Data Structures and Algorithms.
Field: Information Security Basics
Output length and security
For an ideal hash function with an n-bit output, finding a preimage by brute force takes about 2^n computations, but thanks to the birthday paradox a collision becomes likely after about 2^(n/2). SHA-256 is therefore considered to have about 128-bit strength against collisions. For MD5 and SHA-1, methods have been found that create collisions with far fewer computations than brute force, so they are not to be used where security is required, such as in digital signatures.
FAQ
What is the difference between a hash function and encryption?
Encryption is a transformation that uses a key and can be reversed (decrypted), whereas a hash function uses no key and is a one-way computation that cannot be reversed. Hash values are therefore used not to keep secrets but to check whether data is the same.
How many bits is a SHA-256 hash value?
256 bits (64 hexadecimal characters), regardless of the input length. A one-character input and a large file both give a value of the same length.