コード例 #1
0
            static void Example1(string text, byte type)
            {
                string alph = "abcdefghijklmnopqrstuvwxyz";
                string key = "";
                string decrypt, encrypt;
                var    pad = new OnTimePad(alph);

                switch (type)
                {
                case 1:
                    key = Changekey(text, 1, 25);
                    Console.WriteLine("Оригинал: " + text);
                    encrypt = pad.Crypt1(text, key, true);
                    File.WriteAllText("key.txt", key);
                    File.WriteAllText("encrypt.txt", encrypt);
                    Console.WriteLine("Шифротекст: " + encrypt);
                    break;

                case 2:
                    encrypt = File.ReadAllText("encrypt.txt");
                    Console.WriteLine("Оригинал: " + encrypt);
                    key     = File.ReadAllText("key.txt");
                    decrypt = pad.Crypt1(encrypt, key, false);
                    File.WriteAllText("decrypt.txt", decrypt);
                    Console.WriteLine("Расшифровка: " + decrypt);
                    break;
                }
            }