#K14806. Caesar Cipher Encryption
Caesar Cipher Encryption
Caesar Cipher Encryption
You are given a string s
consisting of lowercase English letters and an integer k
. Your task is to encrypt the string using a Caesar cipher. In a Caesar cipher, each letter is shifted by k
positions in the alphabet. The transformation follows the formula:
\( new\_char = \left( (ch - 'a' + k) \mod 26 \right) + 'a' \)
For example, if s = "hello"
and k = 3
, then the resulting string will be "khoor". The shift wraps around so that after 'z', it returns to 'a'.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line is a string
s
of lowercase English letters. - The second line is an integer
k
representing the shift.
outputFormat
Output the encrypted string to the standard output (stdout).
## samplehello
3
khoor