示例#1
0
 private void StartEncryption(object sender, RoutedEventArgs e)
 {
     if (uploadedImg.Source == null)
     {
         ShowMessageBox("Зображення для зашифровки не завантажено!", "Warning");
         return;
     }
     window.Cursor = Cursors.Wait;
     try
     {
         if (Encryption.currentAlg == 0)
         {
             processedImg.Source = TranspositionAlg.Encrypt(uploadedImg.Source as BitmapSource);
         }
         else
         {
             processedImg.Source = SymetricAlg.RunAlg(uploadedImg.Source as BitmapSource, 0);
         }
     }
     catch (Exception err)
     {
         ShowMessageBox(err.Message.ToString(), "Error");
         window.Cursor = Cursors.Arrow;
         return;
     }
     decrypted     = false;
     window.Cursor = Cursors.Arrow;
 }
示例#2
0
 private void StartDecryption(object sender, RoutedEventArgs e)
 {
     if (decrypted)
     {
         ShowMessageBox("Ви вже розшифровували це зображення!\nЗашифруйте знову!", "Warning");
         return;
     }
     if (Encryption.algParams.Count < (Encryption.currentAlg == 0 ? 5 : 4))
     {
         ShowMessageBox("Ключ розшифровки не завантажено!", "Warning");
         return;
     }
     if (uploadedImg.Source == null)
     {
         ShowMessageBox("Зображення для розшифровки не завантажено!", "Warning");
         return;
     }
     window.Cursor = Cursors.Wait;
     try
     {
         var image = currentAction == 0 ? processedImg.Source as BitmapSource : uploadedImg.Source as BitmapSource;
         if (Encryption.currentAlg == 0)
         {
             processedImg.Source = TranspositionAlg.Decrypt(image);
         }
         else
         {
             processedImg.Source = SymetricAlg.RunAlg(image, 1);
         }
     }
     catch (Exception err)
     {
         ShowMessageBox(err.Message.ToString(), "Error");
         window.Cursor = Cursors.Arrow;
         return;
     }
     decrypted     = true;
     window.Cursor = Cursors.Arrow;
 }