WEP uses the stream cipher $RC4$ for confidentiality and the CRC-32 checksum for integrity. All data frames sent by a router in a WEP protected network are encrypted. When a router sends a packet, the following steps are executed.
The router picks a $24$-bit value called the initialization vector $IV$.
A new $IV$ is used for every packet.
The $IV$ is prepended to the key (password you enter) and
forms the per packet key $K$.
A CRC32 checksum of the payload is produced and appended to the
payload. This checksum is called an Integrity Check value ($ICV$).
The per packet key $K$ is fed into the $RC4$ stream cipher to produce a
key stream $X$ of the length of the payload with checksum.
The plaintext with the checksum is XORed with the key stream and
forms the cipher text of the packet.
The cipher text, the $IV$ and some additional header fields are used
to build a packet, which is now sent to the receiver.
Weaknesses of WEP and why to choose WPA
An $IV$ size of $24$-bits provides only $16$ million different key streams for a given WEP key. If the $IV$ is reused, the key stream for a given $IV$ is found and hence an attacker can decrypt subsequent packets that were encrypted with the same $IV$ even without knowing the WEP key.
Since there are only $16$ million $IV$ values, how the $IV$ is chosen makes a big difference in the attacks based on $IV$. As explained above, some implementations choose $IV$s randomly and some are assigned sequentially. With a randomly chosen $IV$, there is a $50\%$ chance of reuse after less than $5000$ packets and if assigned sequentially, collisions are inevitable if the values are re-initialized.
WEP’s integrity check field is implemented as a CRC-32 checksum, which is part of the encrypted payload of the packet. However, CRC-32 is linear, which means that it is possible to compute the bit difference of two CRCs based on the bit difference of the messages over which they are taken. In other words, flipping bit ‘$n$’ in the message results in a deterministic set of bits in the CRC that must be flipped to produce a correct checksum on the modified message. An attacker can therefore change a bit in an encrypted message and know which bit of the encrypted $ICV$ will change as a result.