Vigenère-like Cipher Encryption

Company: Citi Bank - Hirepro_14thjuly

Difficulty: medium

Problem Statement

Vigenere-like Cipher Encryption Write a program that encrypts a text message with a key word. Every letter of the key stands for a shift value equal to its distance from the letter a : a has distance 0, b has distance 1, and so on up to z , which has distance 25. The letters of the message are shifted forward, one by one, by the shift values of the key letters: the first message letter uses the first key letter, the second message letter uses the second key letter, and so on. When the key is shorter than the message, the key letters are reused cyclically from the start of the key. When the key is longer than the message, its extra letters are not used. A shift that goes past z wraps around to a . Formally, if the key is K (length k ) and the message is T , the encrypted letter at index i (0-based) is the letter at distance (dist(T[i]) + dist(K[i mod k])) mod 26 from a . Complete the function encrypt(key, message) , which returns the encrypted text message E . Input Format The first lin