There are basically three types of hackers: white hats, black hats and grey hats.
To understand these, lets first know what a hacker is.
A hacker is someone who seeks and exploits weaknesses in a computer system or computer online grid.
They normally notify the vendor once they discover a vulnerability in software so that the flaw can be fixed.
White hats are also considered as ethical hackers.
They may then offer to correct the defect for a fee.
The governments use those security holes to hack into the systems of adversaries or criminal suspects.
source: www.techworm.net