Imagara 3 年之前
父節點
當前提交
c6267dc0d0
共有 2 個文件被更改,包括 69 次插入10 次删除
  1. 11 4
      Encrypter/MainWindow.xaml
  2. 58 6
      Encrypter/MainWindow.xaml.cs

+ 11 - 4
Encrypter/MainWindow.xaml

@@ -31,16 +31,23 @@
                                 HorizontalAlignment="Center"
                                 Grid.Column="0">
                         <Label Content="Ввод"/>
-                        <TextBox Width="200" 
+                        <TextBox Name="sposob1_input"
+                                 Width="200" 
                                  Height="40"/>
                         <Label Content="Результат"/>
-                        <TextBox Width="200" 
+                        <TextBox Name="sposob1_output"
+                                 Width="200" 
                                  Height="40"/>
                         <Button Width="200"
                                 Height="40"
-                                Content="Зашифровать"/>
+                                Content="Зашифровать"
+                                Click="sposob1_encrypt"/>
                     </StackPanel>
-
+                    <TextBox Visibility="Collapsed"
+                             Name="KeyBox"
+                             Grid.ColumnSpan="2"
+                             Width="200"
+                             Height="40"/>
                     <StackPanel Orientation="Vertical"
                                 VerticalAlignment="Center"
                                 HorizontalAlignment="Center"

+ 58 - 6
Encrypter/MainWindow.xaml.cs

@@ -21,11 +21,65 @@ namespace Encrypter
     public partial class MainWindow : Window
     {
         Encoding ascii = Encoding.ASCII;
+        Encoding unicode = Encoding.Unicode;
+        
+
         public MainWindow()
         {
             InitializeComponent();
         }
+        private void sposob1_encrypt(object sender, RoutedEventArgs e)
+        {
+
+            Dictionary<char, int> dictionarys = sposob1_input.Text.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
+            int uniqueSymbCount = dictionarys.Count();
+
+
+
+
+
+
+            char[] symb = dictionarys.Select(q => q.Key).ToArray();
+
+            char[] newSymb = new char[uniqueSymbCount];
+
+            //foreach (KeyValuePair<char, int> keyValuePair in dictionarys)
+            //{
+            //    //keyValuePair.Value;
+            //    MessageBox.Show($"{keyValuePair.Key} : {keyValuePair.Value}");
+            //}
+            byte startSymb = 100;
+
+
+            for (int i = 0; i < newSymb.Length; i++)
+            {
+                newSymb[i] = Encoding.Unicode.GetChars(startSymb);
+                startSymb++;
+                MessageBox.Show(newSymb[i].ToString());
+            }
 
+            //foreach (char c in sposob1_input.Text)
+            //{
+            //    for(int i = 0;i<)
+            //}
+
+            //foreach (char c in symb)
+            //    MessageBox.Show(c.ToString());
+        }
+        private void sposob1_decrypt(object sender, RoutedEventArgs e)
+        {
+
+
+        }
+        private void sposob2_encrypt(object sender, RoutedEventArgs e)
+        {
+
+        }
+        private void sposob2_decrypt(object sender, RoutedEventArgs e)
+        {
+
+
+        }
         private void sposob3_encrypt(object sender, RoutedEventArgs e)
         {
             string input = sposob3_input.Text, output = "";
@@ -39,16 +93,14 @@ namespace Encrypter
             string input = sposob3_input2.Text;
             int count = input.Count(c => c == '%');
             string output = "";
-            while(input.IndexOf($"%{count}^?") != -1)
+            while (input.IndexOf($"%{count}^?") != -1)
             {
                 byte temp = Convert.ToByte(Convert.ToInt32(input.Substring(0, input.IndexOf($"%{count}^?"))) - count);
                 output += Convert.ToChar(temp);
-                MessageBox.Show("output = " + output);
-                input = input.Remove(0, output.Length+4);
-                MessageBox.Show("input = " + input);
-            }    
+                input = input.Remove(0, input.IndexOf($"%{count}^?") + 3 + count.ToString().Length);
+            }
             sposob3_output2.Text = output;
 
         }
     }
-}
+}