Step by step
- You generate a key pair: public key + private key.
- You share your public key. You keep your private key secret.
- When A wants to message B, A first gets B’s public key (from a key manager/directory, or directly).
- A creates a one‑time session key (a random symmetric key).
- A encrypts the message with the session key (fast encryption).
- A encrypts the session key with B’s public key and attaches it.
- Optional: A signs the message with A’s private key.
- B uses B’s private key to unlock the session key and decrypt the message.
- If signed: B verifies the signature using A’s public key.
Result: confidentiality (only B can read) and integrity/authenticity (if signed).