Cipher Message Decryption

Company: Mastercard_7aug

Difficulty: medium

Problem Statement

Cipher Message Decryption Problem Description Ramesh worries that his email conversations could be read by a "man in the middle", so he invents a substitution cipher. The cipher is defined by a key string Str , which is a permutation of the 26 lowercase English letters. To decrypt a cipher message, line Str up under the alphabet abcdefghijklmnopqrstuvwxyz . The letter at position i of the alphabet in the cipher message becomes the letter at position i of Str in the original message . So with Str = "bmqhljeztxicvprsunafkdwogy" , the cipher letter a becomes b , b becomes m , c becomes q , and so on until z becomes y . Decryption follows these rules, applied to every character of the cipher message: A lowercase letter c is replaced by Str[c - 'a'] (0-based). An uppercase letter is replaced in the same way and the result stays uppercase. For example, B becomes M when b becomes m . Every underscore _ is replaced by a space. Every other character ( ' , - , , , . , ! , ? , : ) is copied uncha