A simple implementation of the Caesar Cipher is to use a string of valid characters and the remainder operator, %
.
char Encrypt_Via_Caesar_Cipher(char letter, unsigned int shift)
{
static const std::string vocabulary = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const std::string::size_type position = vocabulary.find(letter);
char c = letter;
if (position != std::string::npos)
{
const std::string::size_type length = vocabulary.length();
c = vocabulary[(position + shift) % length];
}
return c;
}