If we want to send $k$ bits of information, we will create a frame that will contain $n$ bits, where $n > k$. We will then create what is called Frame Check Sequence (FCS) (which has a length of $n-k$ bits), that is, some bits that we will append to the end of the data to create the final frame that we actually send.
To compute this we will use Modulo 2 Arithmetic (means that we will make a lot of XOR operations).
Some quick examples of this type of arithmetic:


As you can see, in this arithmetic addition and subtraction gives the same result.
We will use a piece of data $D$ and a pre-determined pattern $P$:

The pattern can be anything, we only need that the sender and the receiver knows the pattern.
We first need to compute the FCS. As shown above, because of our choices FCS will have a length of 5. Therefore, to compute the FCS, we add 5 zeroes to the end of our data and divide the bits by Modulo 2 with the pattern. Modulo 2 division is basically we first take the leftmost section of the same length as our pattern from our data, and subtract to that section the pattern multiplied by 1. Afterwards, we add add the next bit every time to the result and subtract again the pattern. If what we are taking down doesn’t fit, just pass (that is, subtract the pattern multiplied by 0) and add the next bit until we can subtract. The FCS will be the remainder of this division (if the length is fewer, add 0s to the left).
Remember that we can disregard starting zeroes from the left, as the number only start when it finds the first one.

So, what does the receiver actually receive? We first take the original data (the 10 bits) and the 5 bits of zeroes is replaced by our FCS found. So, the actual frame sent is:

And how does the receiver know if any error happens? It does again Modulo 2 division with the pattern (as a result, the receiver must also know the pattern):

As the remainder is all 0s, we know that the message is correct. If we get a different result, data has been lost/damaged.