Loading Now

caesarian

Caesarian shift (Caesar cipher) is a method used in cryptography where a string message is encrypted by shifting the letters n times. For more information, see this wiki page.

You are given an integer n, which can be positive, negative or zero. Positive values indicate right shifts, and negative values indicate left shifts.

Given a message and n, return message encrypted by the shift n.

Example

  • For message = "abc" and n = 3, the output should be caesarian(message, n) = "def".

    "a" shifted to the right 3 times becomes “d", "b"becomes "e" and "c" becomes "f".

  • For message = "egg" and n = -1, the output should be caesarian(message, n) = "dff".

Input/Output

  • [execution time limit] 0.5 seconds

  • [input] string message

    The message to be encrypted.

    Constraints:

    0 ≤ message.length ≤ 500.

  • [input] integer n

    The shift value.

    Constraints:

    -2 · 109 ≤ n ≤ 2 · 109.

  • [output] string

    • Encrypted message.

Post Comment

Contact