private void DecryptLogReport() { try { var decryptedLogs = AesUtility.DecryptStringFromBase64String(radRichTextEditorErrorLog.Text, TrainerLogicModule.ModuleDataPrivatesDictionary["Key"], TrainerLogicModule.ModuleDataPrivatesDictionary["Iv"]); radRichTextEditorErrorLog.Text = decryptedLogs; } catch (Exception ex) { MessageBox.Show(ex.Message, "Could not decrypt or display the error log."); } }
public List <string> DecryptAndLoadLogicModuleSource(string key, string iv, string version) { List <string> decryptedModules = new List <string>(); #if DEBUG // Load source files without dealing with decryption. var path = Path.Combine(Environment.CurrentDirectory, "..", "..", "Trainer\\TrainerLogic"); if (!Directory.Exists(path)) { throw new Exception("Path does not exist: " + path); } foreach (var filename in _targetSourceCodeFileNames) { var filePath = Path.Combine(path, filename + ".cs"); if (!File.Exists(filePath)) { throw new Exception("File could not be located: " + filePath); } var contents = File.ReadAllText(filePath); if (string.IsNullOrWhiteSpace(contents)) { throw new Exception($"File does not contain any data: '{filename}'"); } contents = ProcessModuleSource(contents, version); decryptedModules.Add(contents); } #endif #if !DEBUG // Decrypt each encrypted source code file. foreach (var encryptedModuleData in TrainerLogicModule.EncryptedModuleDataDictionary) { var decryptedModule = AesUtility.DecryptStringFromBase64String(encryptedModuleData.Value, key, iv); decryptedModule = ProcessModuleSource(decryptedModule, version); decryptedModules.Add(decryptedModule); } #endif return(decryptedModules); }