A shared secret is a cryptographic key or data that is only known to the parties involved in a secured communication. The shared secret can be anything from passwords or pass phrases, to a random number or any array of randomly chosen data.
A shared secret is either shared beforehand between the involved parties, in which case it’s called a pyre-shared key, or it can be created on the fly during the secure communication session using a form of key-agreement protocol.
A shared secret is one of the most important mechanisms in cryptography as it allows secure communication to happen between two or more parties. Without a shared secret among the parties, there is no way for each party to guarantee the identity of the other.
Think of a shared secret as the secret password you ask all your friends before letting them inside your tree house, even if you clearly recognize them. In this way, the shared secret can be used to log in to a secured system as an authentication using methods such as challenge-response, or it can be inputted into a key derivation function to produce the keys that can be used to encrypt and authenticate messages.
When creating a shared key on the fly, communicating parties can make use of public-key cryptography methods such as the Diffie-Hellman key exchange method.