6.4.
Write a simple encryption program using string functions which apply the substitution method. Here is the given Substitution Table.
Substitution Table:
A *
E $
I /
O +
U -‐
Sample input/output dialogue:
Enter message: meet me at 9:00 a.m. in the park
Encrypted message: m$$t m$ *t 9:00 *.m. /n th$ p*rk
internal class Program
{
static void Main()
{
Console.Write("Enter message: ");
string str = Console.ReadLine();
string code = "";
string letter = str.ToUpper();
for (int i = 0; i < str.Length; i++)
{
switch (letter[i])
{
case 'A':
{
code += "*";
break;
}
case 'E':
{
code += "$";
break;
}
case 'I':
{
code += "/";
break;
}
case 'O':
{
code += "+";
break;
}
case 'U':
{
code += "-";
break;
}
default:
{
code += str[i];
break;
}
}
}
Console.WriteLine($"Coded value: {code}");
Console.ReadKey();
}
}
Comments
Leave a comment