#C7719. Substitution Cipher Encoder
Substitution Cipher Encoder
Substitution Cipher Encoder
Given a substitution cipher key and a message, encode the message by substituting each letter using the mapping defined by the key. The key must be a permutation of the 26 lowercase English letters. For each letter \(c\) in the message, if \(c\) is in the range 'a' to 'z', then it is replaced by the letter at the corresponding position in the key (i.e. if \(c\) is the \(i\)-th letter of the alphabet, with \(a\) corresponding to \(i=0\), then it is replaced by the \(i\)-th letter of the key). Non-alphabet characters remain unchanged. If the key is invalid, output Invalid key.
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line is a string representing the substitution key, and the second line is the message to be encoded.
outputFormat
Output the encoded message to standard output (stdout) as a single line. If the key is invalid, output 'Invalid key'.## sample
bcdefghijklmnopqrstuvwxyza
hello world
ifmmp xpsme