# hash functions preimage and second collision resistance [duplicate]

A hash function H is secure in terms of pre-image resis-tance. Does this imply that H has second pre-image (aka weak collision) resistance?

• Hint: Look at what is broken about MD5. – SEJPM Oct 4 '15 at 18:29

Assume we are given a one-way function $f: \{0,1\}^m \rightarrow \{0,1\}^n$. Now consider the function $f': \{0,1\}^{m+1} \rightarrow \{0,1\}^n$ that simply applies $f$ to the first $m$ input bits and ignores the last bit. This function is still one-way / preimage resistant as a preimage finder $A$ for $f'$ immediately leads a preimage finder $A'$ for $f$ ($A'$ simply runs $A$ and returns the first $m$ bits of its output). On the other hand, it is trivial to find second-preimages for $f'$: Simply flip the last bit.