Computer decryption algorithms and knowing the solution
===

This is a general question about using computers to decrypt information. It has puzzled me for a while.

The question is really two parts:

 1. How does a computer check if a "guessed" key is the correct key? A human could do it because the result is readable - to humans. SO what does it mean to say the computer is checking a key?


 2. How does the alogirthm know it has found the correct key? For example if  the computer just brute force checks possible keys one-by-one (if it uses a better algorithm for this it isn't so relevent), at what point does it stop and say "this is the key and message!"?