This is the base concept behind asymmetrical cryptography (https://en.wikipedia.org/wiki/Public-key_cryptography). You can share your public key with anyone, so that one can encrypt a message that only you can read (owner of the private key derived from the public key).