A black hat is a malicious type of computer hacker or cracker who enters into a computer system or network with a sinister intent.
A black hat is a villain or bad guy in Western movies who actually wears a black hat and all black clothing. In the Wild West he was also looked upon as a bounty hunter.