The best way to understand Caesar cipher is to write down the letters from A to Z and assign an index, from 0 to 25, to these letters, as follows In other words, 'A' corresponds to index 0, 'B' corresponds to index 1, and so on. A group of all the letters from A to Z is called the character set:
Now, let's say you want to shift the letters by three positions, then 3 becomes your key. To encrypt the letter 'A', add the index of letter A, which is 0, to the key 3; this results in 0+3 = 3. Now use the result 3 as an index to find the corresponding letter, which is 'D', so 'A' is encrypted to 'D'. To encrypt 'B' ...