Esempio n. 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (IsEncode)
     {
         before.Text = VizhenerAlgorithm.Encode(after.Text, key.Text);
     }
     else
     {
         after.Text = VizhenerAlgorithm.Decode(before.Text, key.Text);
     }
 }
Esempio n. 2
0
 public static (string, string) Download(bool isEncode, string key, string p = default)
 {
     (string, string)res = (null, null);
     if (p == default)
     {
         var path = GetPath();
         if (path != null)
         {
             if (!isEncode)
             {
                 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                 res.Item2 = File.ReadAllText(path, Encoding.GetEncoding("windows-1251"));
                 res.Item1 = VizhenerAlgorithm.Decode(res.Item2, key);
             }
             else
             {
                 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                 res.Item1 = File.ReadAllText(path, Encoding.GetEncoding("windows-1251"));
                 res.Item2 = VizhenerAlgorithm.Decode(res.Item1, key);
             }
         }
     }
     else
     {
         if (!isEncode)
         {
             Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
             res.Item2 = File.ReadAllText(p, Encoding.GetEncoding("windows-1251"));
             res.Item1 = VizhenerAlgorithm.Decode(res.Item2, key);
         }
         else
         {
             Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
             res.Item1 = File.ReadAllText(p, Encoding.GetEncoding("windows-1251"));
             res.Item2 = VizhenerAlgorithm.Decode(res.Item1, key);
         }
     }
     return(res);
 }