It depends on the exact algorithm used for encryption, but a decryption does not have to be identical to the encryption (though that is a poor way to say it)
But what I think you are referring to are the common public/private key exchanges that take place between individuals, CA, and servers, etc.
Basically you make an encryption with more than one answer, but only give one answer to a second party. As long as the originating party keeps their half 'private' you always know messages, or what have you, come from them.