What is a Hash Function?
A hash function is an efficiently implementable function that converts data of any size into a number of fixed size. Typical output sizes in bits are 128 (used by MD4, MD5, RIPEMD), 160 (used by SHA-1, RIPEMD-160), 256 (SHA2-256), 512 (SHA2-512). There are several security requirements that exist for cryptographic hash functions (source: Wikipedia entry for pre-image attack): • One-way property or first pre-image resistance – difficulty of producing an input that corresponds to a given (random) output. In other words, given a hash value h, it is infeasible to find a message m such that hash(m) = h; • Second pre-image resistance – difficulty of finding a second input that produces the same output as given known input would produce. In other words, given a fixed message m1, it is infeasible to find a different message m2 such that hash(m2) = hash(m1); • Collision-free property – difficulty of producing a pair of different inputs that lead to the same output.