The same idea in every language
Each tutorial comes down to one calculation. Turn the letter into a number from 0 to 25, add the shift, wrap around with modulo, then turn the number back into a letter:
E(x) = (x + k) mod 26Decrypting subtracts the shift instead, and that is where most bugs appear. In C, Java, JavaScript and PHP the % operator can return a negative number, while Python’s cannot, so outside Python you write (x - k + 26) % 26.
Tutorial, API or library?
Follow a tutorial when you want to understand the code or have an assignment to hand in. The REST API suits a project in any language: it takes a plain HTTP request, needs no sign-up, and allows 60 requests per minute per IP address. For JavaScript and TypeScript projects, the caesar-cipher-js library saves you the request.
Whichever you pick, this is code for learning and puzzles. Passwords and user data need modern encryption from a maintained library.