6.5.
Write a simple decryption program using string functions which will apply the Substitution Method. Here is the given Substitution Table.
Substitution Table:
* A
$ E
/ I
+ O
-‐ U
Encrypted message: m$$t m$ *t 9:00 *.m. /n th$ p*rk
Decrypted message: meet me at 9:00 a.m. in the park
internal class Program
{
static void Main()
{
Console.Write("Enter code: ");
string code = Console.ReadLine();
string message = "";
for (int i = 0; i < code.Length; i++)
{
switch (code[i])
{
case '*':
{
message += "A";
break;
}
case '$':
{
message += "E";
break;
}
case '/':
{
message += "I";
break;
}
case '+':
{
message += "O";
break;
}
case '-':
{
message += "U";
break;
}
default:
{
message += code[i];
break;
}
}
}
Console.WriteLine($"Message: {message.ToLower()}");
Console.ReadKey();
}
}
Comments
Leave a comment