BB84
BB84 is the first protocol ever proposed for quantum key distribution (QKD): a way for two people, traditionally called Alice and Bob, to agree on a secret string of random bits while being able to notice if anyone was listening. The clever part is not that it transmits a message secretly, but that it lets you build a shared key and check afterward whether the channel was clean. Picture Alice sending one photon at a time, and for each one she flips two private coins: one decides the bit (0 or 1), the other decides which of two 'orientations' she uses to encode it. Bob, who can't read her mind, picks an orientation at random too when he measures each photon.
After all the photons are sent, Alice and Bob talk over an ordinary public line and compare only which orientations they chose, never the bit values. Whenever they happened to pick the same orientation, Bob's reading is reliable, and they keep those bits; the rest they throw away. Here is where the physics earns its keep: because of the no-cloning theorem, an eavesdropper cannot copy an unknown photon to inspect it later, and any attempt to measure it in the wrong orientation disturbs it. So an eavesdropper is forced to guess orientations too, and her guesses introduce errors. By sacrificing a small sample of their kept bits and checking the error rate, Alice and Bob can detect that tampering. If the channel looks clean, the remaining bits become a shared secret key; if not, they discard everything and try again.
It helps to be clear about what BB84 does and does not promise. It is not a faster computer and has nothing to do with Shor's algorithm or breaking RSA. It is a key-exchange method whose security rests on the laws of physics rather than on a hard math problem, which is what distinguishes it from post-quantum cryptography (classical algorithms designed to resist quantum attacks). In practice BB84 needs a genuine quantum channel such as fiber or free-space optics, real hardware is imperfect and limited in range, and it secures only the key-distribution step, not your whole communication system.
The two encoding orientations BB84 uses are non-commuting bases: the rectilinear basis {|0>, |1>} and the diagonal basis {|+>, |->}, where |+> = (|0> + |1>)/sqrt(2) and |-> = (|0> - |1>)/sqrt(2).
BB84 detects eavesdropping and produces a shared key; it does not encrypt messages by itself and is not a defense built into general-purpose quantum computers.