I am trying to perform a wrap around of the ASCII alphabet characters in order to perform a shift from a key. For example, if the key is 2 then shift the letter A
to become C
. But, how do I wrap around Z
in order to get to B
using modulus arithmetic?
I am trying to implement the following formula:
ci = (pi + key) % 26;
Where ci
is the i
th ciphered letter and pi
is the i
th letter to be ciphered.