private static void Main(string[] args) { CliOptions baseOptions = new CliOptions(); if (!Parser.Default.ParseArguments(args, baseOptions, (s, o) => { OptionVerb = s; Options = o; })) { Environment.Exit(Parser.DefaultExitCodeFail); } switch (OptionVerb) { case "decrypt": { DecryptEsd((DecryptOptions)Options); break; } case "update": { UpdateKeys((UpdateOptions)Options); break; } } }
private static void Main(string[] args) { Options = new CliOptions(); if (!Parser.Default.ParseArguments(args, Options)) { return; } if (string.IsNullOrEmpty(Options.CustomKey)) { CryptoKey.LoadKeysFromXml(); } else { try { CryptoKey.UseCustomKey(Options.CustomKey); } catch (FormatException) { Console.WriteLine("The key you have specified is not valid. Loading the keys from the XML file instead..."); CryptoKey.LoadKeysFromXml(); } } foreach (string file in Options.EsdFiles) { if (File.Exists(file)) { try { using (WimFile wf = new WimFile(file)) { wf.DecryptEsd(); } } catch (NoValidCryptoKeyException) { Console.WriteLine($"We could not find the correct CryptoKey for \"{file}\"."); } catch (UnencryptedImageException) { Console.WriteLine($"You are trying to decrypt \"{file}\", but it is already decrypted."); } } else { Console.WriteLine($"The file \"{file}\" does not exist."); } } }