public char[] EngCommon = {'e','t','a','o','i','n','s','h','r','d','l','u','c','m','w','f','y','g','p','b','v','k','x','j','q','z'};
public override String Description() { return "Subsitution cipher suite\nKey format is \"E[EEE]=d[ddd]\", where E is the character in the cipher and d is the intended character in the workspace."; }
public override String Command() { return "sub"; }
public Substitution(Workbench w) : base (w) {}
/// <summary>
/// We should be able to act on a workspace and command line. Most ciphers will sue the same syntax. Those that don't can override.
/// </summary>
/// <param name=workSpace>The current version of the text being worked on.</param>
/// <returns>The updated version of the workSpace</returns>
public override String RunCommand(String workSpace,String inputText,String[] line) {
if (workSpace == null || line == null || line.Length < 2) {
Console.Error.WriteLine("Malformed request.");
return workSpace;
}
switch (line[1]) {
case "encrypt":
return Encrypt(workSpace,inputText,line);
case "decrypt":
return Decrypt(workSpace,inputText,line);
case "try-common":
return TryCommon(inputText);
case "help":
GetHelp();
return workSpace;
default:
Console.Error.WriteLine("Invalid command. Type help for more.");
return workSpace;
}
}
/// <summary>
/// Show the helptext for this cipher. By default, most ciphers will only have encrypt, decrypt, and help functions.
/// </summary>
/// <param name=line>This is the incoming line and we use it to get the cipher name</param>
public override void GetHelp() {
Console.WriteLine(String.Format("Help for the {0} cipher suite.\n{1}\n",Command(),Description()));
Console.WriteLine("encrypt key[s] -- encrypt with the key[s]\ndecrypt key[s] -- decrypt with the key[s]\ntry-common -- try common sub keys\nhelp -- show this helptext.");