Пример #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine(help);
                return;
            }

            var table = new ReplaceTable();

            if (File.Exists(rep_config))
            {
                table.LoadList(rep_config);
            }
            else
            {
                table.GenerateList();
                table.WriteList(rep_config);
            }

            string command = args[0];

            switch (command)
            {
            case "font":
                if (args.Length <= 1)
                {
                    Console.WriteLine(help);
                    return;
                }
                string input  = args[1];
                string output = font_output;
                if (args.Length == 3)
                {
                    output = args[2];
                }

                FontHandler fontHandler = new FontHandler(table);
                fontHandler.Open(input, output);

                break;

            case "text":
                bool decode = false;
                if (args.Length == 2 && args[1] == "decode")
                {
                    decode = true;
                }

                Console.WriteLine((decode ? "文本解密模式" : "文本加密模式") + " 请在此处输入文字: ");

                var rep = new Replacer(table);
                while (true)
                {
                    var str = Console.ReadLine();
                    if (str == "")
                    {
                        break;
                    }
                    if (decode)
                    {
                        Console.WriteLine(rep.Decode(str));
                    }
                    else
                    {
                        Console.WriteLine(rep.Encode(str));
                    }
                }
                break;

            default:
                Console.WriteLine(help);
                return;
            }
        }
Пример #2
0
 public Replacer(ReplaceTable table)
 {
     this.table = table;
 }
Пример #3
0
 public FontHandler(ReplaceTable table)
 {
     this.table = table;
 }