.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 -
using System;
using System.Text;
namespace Test
{
class CapitalTest
{
static void Main()
{
Console.Write("Enter the string: ");
string str = Console.ReadLine();
StringBuilder sb = new StringBuilder();
for(int i = 0; i < str.Length; ++i)
{
switch(str[i])
{
case 'A': sb.Append('*'); break;
case 'E': sb.Append('$'); break;
case 'I': sb.Append('/'); break;
case 'O': sb.Append('+'); break;
case 'U': sb.Append('-'); break;
default: sb.Append(str[i]); break;
}
}
Console.WriteLine("Encrypted string: " + sb.ToString());
}
}
}
Comments
Leave a comment