#K39202. Caesar Cipher Encryption
Caesar Cipher Encryption
Caesar Cipher Encryption
You are provided with a plaintext message and an integer shift value. Your task is to implement the Caesar cipher encryption algorithm. The cipher works by shifting each alphabetical character by the given number of positions while preserving their case. Characters that are not letters (such as punctuation, digits, and whitespace) remain unchanged. When shifting a letter beyond 'Z' or 'z', it wraps around to the beginning of the alphabet. Mathematically, the transformation for each letter is given by
$$\text{new} = (\text{old} - \text{base} + \text{shift}) \mod 26 $$where (\text{base}) is the ASCII code of 'A' for uppercase letters and 'a' for lowercase letters.
inputFormat
The input consists of two lines. The first line contains the string message. The second line contains an integer representing the shift value.
outputFormat
Output the encrypted message on a single line.## sample
Hello, World!
0
Hello, World!