Ejemplo n.º 1
0
 public static void EncryptByteArray(ref byte[] byteArray)
 {
     try
     {
         if (Globals.MemoryEncryption == true && byteArray != null)
         {
             if (Constants.RunningOnMono == false)
             {
                 // Windows
                 ProtectedMemory.Protect(byteArray, MemoryProtectionScope.SameProcess);
             }
             else if (Constants.RunningOnMono == true)
             {
                 // Linux & macOS
                 byteArray = SealedPublicKeyBox.Create(byteArray, _keyPair.PublicKey);
             }
         }
     }
     catch (Exception ex) when(ExceptionFilters.MemoryEncryptionExceptions(ex))
     {
         Globals.MemoryEncryption = false;
         Settings.SaveSettings();
         Logging.LogException(ex.ToString(), Logging.Severity.Bug);
         DisplayMessage.ErrorMessageBox(ex.GetType().Name, "Memory encryption has been disabled due to an exception. This is a bug - please report it.");
     }
 }
Ejemplo n.º 2
0
 public static void DecryptByteArray(ref byte[] byteArray)
 {
     try
     {
         if (Globals.MemoryEncryption == true && byteArray != null)
         {
             if (Constants.RunningOnMono == false)
             {
                 // Windows
                 ProtectedMemory.Unprotect(byteArray, MemoryProtectionScope.SameProcess);
             }
             else if (Constants.RunningOnMono == true)
             {
                 // Linux & macOS
                 byteArray = SealedPublicKeyBox.Open(byteArray, _keyPair);
             }
         }
     }
     catch (Exception ex) when(ExceptionFilters.MemoryEncryptionExceptions(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.Bug);
         DisplayMessage.ErrorMessageBox(ex.GetType().Name, "Memory decryption failed. This is a bug - please report it.");
     }
 }