In: Computer Science
IUHHKIN NAHKK KBNHT VUOYNG
T |
Z |
I |
J |
K |
M |
W |
A |
O |
P |
Q |
R |
S |
Y |
U |
V |
L |
H |
G |
N |
E |
C |
D |
B |
F |
X |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
O |
P |
Q |
R |
S |
T |
U |
V |
W |
X |
Y |
Z |
-> We can map each key of cypher text unit to its value.
-> After the mapping is done, we need to replace each character in cypher text with its mapped value, using the character as key.
->assume "Map" stores the mapping.
-> Map[key] = value assigns the charcter value to the key character.
-> Now we assign the above values:
key | T | Z | I | J | K | M | W | A | O | P | Q | R | S | Y | U | V | L | H | G | N | E | C | D | B | F | X |
values | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | A |
Algorithm to obtain message from cypher text:
// cypher_to_message will print the message text and take the mapping and cypher text as input
Cypher_to_message( Map, cypher_text )
{
// len stores the length of cypeher text
len = length_of (cypher_text);
// following line denotes that message text will also have length = len
message_text [ len ];
// for each index of message text we decide the which character is to be stored
// if we have mapping in Map for ith character of cypher text then we assign its mapped value to
message_text[i]
// but if mapping is not present then message_text[ i ] will be equal to cypher_text[ i ]
for each index i in range 0 to len-1:
{
if ( we have mapping for cypher_text[ i ] )
message_text [ i ] = Map[ cypher_text[ i ] ] ;
else
message_text [ i ] = cypher_text[ i ] ;
}
print( message[text] );
}
For cypher_text = IUHHKIN NAHKK KBNHT VUOYNG
message_text = THREE EXTRA POINTS