The idea is just to shift characters. So lets say lets say I wanted to shift by 5, then A becomes F, B becomes G, ... etc...
in the computer characters are repersented by numbers... for most part this is
ASCII which, although an older standard, is the normal way to represent text data in a computer.
So when you type in an A the computer stores the number 65... 65+5=70 which is the code for F...
So to caesar cipher the string HELLO WORLD we get:
72 69 76 76 79 32 87 79 82 76 68 -> 78 74 81 81 84 32 92 84 81 73
HELLO WORLD -> NJQQT \TWQI
Note that the W turned into a symbol... this is a slight bug, but how to fix it? well basically we need to wrap the numbers at 91 -> 65. I would do this using the mod operator myself, but you can actually just use an if-statement.
if (cypherLetter > 'Z') { cypherLetter-=26; }This makes:
72 69 76 76 79 32 87 79 82 76 68 -> 78 74 81 81 84 32 66 84 81 73
HELLO WORLD -> NJQQT BTWQI
If encryption is addition, then decryption is subtraction.