#K6126. Encrypting Messages with a Shift Cipher
Encrypting Messages with a Shift Cipher
Encrypting Messages with a Shift Cipher
You are given a string message
consisting of lowercase English letters and an integer shift
. Your task is to encrypt the message using a Caesar cipher. For each character in the message, shift it by the given number of positions in the alphabet. If the shift goes past 'z', it wraps around to 'a'.
The transformation for each character ch is given by:
$$ new\_char = 'a' + ((ch - 'a' + shift) \mod 26) $$
Write a program that reads the message
and shift
from standard input and prints the encrypted message to standard output.
inputFormat
The input consists of two lines:
- The first line contains the string
message
(only lowercase letters). - The second line contains an integer
shift
which represents the shift value.
outputFormat
Output the encrypted message as a single string.
## samplehello
3
khoor