Answer to Question #325776 in C# for chi

Question #325776

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


1
Expert's answer
2022-04-11T07:44:07-0400
using System;

namespace encryption
{
    class Program
    {
        public static void Main(string[] args)
        {
            string mess, encrypt;
            int i;
            char[,] Substitution =
            {
                { 'A', '*'},
                { 'E', '$'},
                { 'I', '/'},
                { 'O', '+'},
                { 'U', '-'}
            };
            Console.Write("Enter message: ");
            mess = Console.ReadLine();
            encrypt = mess;
            
            for (i=0; i < 5; i++)
            {
                encrypt = encrypt.Replace(Char.ToLower(Substitution[i,0]), Substitution[i,1]);
                encrypt = encrypt.Replace(Substitution[i,0], Substitution[i,1]);
            }
            Console.WriteLine("\nEncrypted message: {0}", encrypt);
            
            Console.Write("\nPress any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS