Since the public key is used to encrypt the message and the private key is used to decrypt the message, then how is it possible for the private key and the public key to be compatible with each other? How can a green key unlock a red-locked door?
This is my way of thinking:
Hello
is encrypted by the public key, becomes %/))=
. The private key then decrypts the message. But since the keys are different, the resulting message may become different from what has been sent - &#(($
, for example.
Of course, I know the encryption/decryption algorithm used in real life is different, but the question is comprehensible. How are the keys made such that one can only encrypt, and the other can only decrypt, while both having enough information so that they are compatible with each other? Is it the algorithm that handles this?