#C4597. Caesar Cipher Encryption
Caesar Cipher Encryption
Caesar Cipher Encryption
This problem involves implementing a Caesar cipher. You are given a string and an integer shift value. You must shift every alphabetical character in the string by the given number of positions while preserving the case of the letters. Other characters (such as punctuation and digits) should remain unchanged. Mathematically, for each letter with a base value (either A for uppercase or a for lowercase), the transformation is given by
[ new_char = (char - base + shift) \mod 26 + base ]
Your task is to apply this transformation and output the resultant string.
inputFormat
The input consists of two lines:
- The first line contains the string to be encrypted.
- The second line contains an integer representing the cipher shift.
outputFormat
Output the encrypted string after applying the Caesar cipher.
## sampleHello, World!
5
Mjqqt, Btwqi!