#K681. Caesar Cipher Encryption
Caesar Cipher Encryption
Caesar Cipher Encryption
You are given a string S
and an integer k
. Your task is to encrypt the string using the Caesar Cipher method. In this cipher, each letter in the string is shifted by k
positions in the alphabet. Note that only alphabetical characters are shifted while all other characters (such as punctuation, spaces, etc.) remain unchanged.
Important: The shifting is cyclic. For instance, if shifting Z
by 1, it becomes A
, and similarly for lowercase letters.
Input constraints: The integer k
may be any integer value. The effective shift is computed modulo 26.
inputFormat
The input consists of two lines:
- The first line contains the string
S
which may contain letters, spaces, and punctuation. - The second line contains an integer
k
, representing the shift amount.
outputFormat
Output a single line containing the encrypted string after applying the Caesar Cipher technique with the given shift value.
## sampleHello, World!
5
Mjqqt, Btwqi!