# Difference between second pre-image resistance attack and collision attack

According to my understanding of hashing algorithms -:

Collision attack is an attack wherein we have a hash(x) and we try to find hash(y) such that x!=y while hash(x)=hash(y).

Second pre-image resistance is where we have a message x and a hash(x) and try to find another message y such that hash(x)=hash(y).

According to me the collision attack and second pre-image resistance attack seems similar as in the case of both, we need to find two different hashes which are same while the message associated with the hash is completely different.

You are mistaken. A collision attack is where you need to find any $x$ and $y$ such that $hash(x)=hash(y)$. Thus, you have much more freedom in finding the collision. This makes it "easier" for the adversary.