static void Main(string[] args) { ////var initial = new byte[] {0x05, 0xe8, 0xbc, 0x26, 0x91, 0xd4, 0x2d, 0xe0, 0x02, 0xf6, 0xf8, 0x44, 0x20, 0x49, 0xe9, 0x3f}; //var init = "THISISADATATESTA"; //var bytes = GetBytes(init); //PrintArray(bytes); //var watch = new Stopwatch(); //IEncryptable encoder = new AESCryptoEncoder(); //watch.Start(); //var encoded = encoder.Encode(bytes, "thisismyfirstkey"); //watch.Stop(); //PrintArray(encoded); //Console.WriteLine(watch.ElapsedMilliseconds + " ms."); //IDecryptable decoder = new AESCryptoDecoder(); //watch.Start(); //var decoded = decoder.Decode(encoded, "thisismyfirstkey"); //watch.Stop(); //PrintArray(decoded); //Console.WriteLine(GetString(decoded)); //Console.WriteLine(watch.ElapsedMilliseconds + " ms."); ////IEncryptable des = new DESCryptoEncoder(); ////var encoded = des.Encode(new byte[] { 0xaa, 0xbb, 0xab, 0x12, 0xff, 0x34, 0xc3, 0xc9 }, new byte[] { 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe }); ////IDecryptable decoder = new DESCryptoDecoder(); ////var decoded = decoder.Decode(encoded, new byte[] {0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe}); //////IEncryptable gost = new GOSTCryptoEncoder(); //////var encoded = gost.Encode(new byte[] { 0xaa, 0xbb, 0xab, 0x12, 0xff, 0x34, 0xc3, 0xc9, 0xaa, 0xbb, 0xab, 0x12 }, new byte[] { 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe, 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe, 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe, 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe }); //////IDecryptable decoder = new GOSTCryptoDecoder(); //////var decoded = decoder.Decode(encoded, ////// new byte[] ////// { ////// 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe, 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe, 0x01, ////// 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe, 0x01, 0x01, 0xcc, 0xcd, 0xdc, 0xfc, 0xed, 0xfe ////// }); IEncryptable gost = new GOSTCryptoEncoder(); var encoded = gost.Encode("ASDADDDDDADA", "qwertyuiqwertyui"); IDecryptable decoder = new GOSTCryptoDecoder(); var decoded = decoder.Decode(encoded, "qwertyuiqwertyui"); Console.ReadKey(); }
private void encodeButton_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(inputTextArea.Text) || String.IsNullOrEmpty(keyTextBox.Text)) { throw new Exception("Не заполнены поля!"); } IEncryptable encoder = new AESCryptoEncoder(); switch ((String)cryptoType.SelectedItem) { case "DES": encoder = new DESCryptoEncoder(); log.Text += String.Format("Алгоритм DES c входными данными длиной {0} байт выполнился за ", inputTextArea.Text.Length*2); break; case "AES128": encoder = new AESCryptoEncoder(); log.Text += String.Format("Алгоритм AES128 c входными данными длиной {0} байт выполнился за ", inputTextArea.Text.Length*2); break; case "ГОСТ 28147-89": encoder = new GOSTCryptoEncoder(); log.Text += String.Format("Алгоритм ГОСТ 28147-89 c входными данными длиной {0} байт выполнился за ", inputTextArea.Text.Length*2); break; default: throw new Exception("Алгоритм не выбран!"); } var timer = new Stopwatch(); timer.Start(); outputTextBox.Text = encoder.Encode(inputTextArea.Text, keyTextBox.Text, isParallel.Checked); timer.Stop(); log.Text += String.Format("{0} ms.{1}", timer.ElapsedMilliseconds, Environment.NewLine); } catch (Exception exception) { log.Text += "ERROR!" + Environment.NewLine; MessageBox.Show(exception.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }