From e798a8dd450e9b8376dded9548c01eaaf814c01e Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Tue, 2 Oct 2018 22:00:57 -0500 Subject: [PATCH] Add key file exporting to hactoolnet --- hactoolnet/CliParser.cs | 4 +++- hactoolnet/Program.cs | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hactoolnet/CliParser.cs b/hactoolnet/CliParser.cs index 0d3f3b07..476912f3 100644 --- a/hactoolnet/CliParser.cs +++ b/hactoolnet/CliParser.cs @@ -202,7 +202,9 @@ namespace hactoolnet sb.AppendLine(" --outdir Specify directory path to save contents to."); sb.AppendLine(" --debugoutdir Specify directory path to save intermediate data to for debugging."); sb.AppendLine(" --sign Sign the save file. (Requires device_key in key file)"); - + sb.AppendLine("Keygen options:"); + sb.AppendLine(" --outdir Specify directory path to save key files to."); + return sb.ToString(); } diff --git a/hactoolnet/Program.cs b/hactoolnet/Program.cs index 7b32c088..cfd2daa7 100644 --- a/hactoolnet/Program.cs +++ b/hactoolnet/Program.cs @@ -97,6 +97,16 @@ namespace hactoolnet { ctx.Keyset.SetSdSeed(ctx.Options.SdSeed.ToBytes()); } + + if (ctx.Options.OutDir != null) + { + string dir = ctx.Options.OutDir; + Directory.CreateDirectory(dir); + + File.WriteAllText(Path.Combine(dir, "prod.keys"), ExternalKeys.PrintCommonKeys(ctx.Keyset)); + File.WriteAllText(Path.Combine(dir, "console.keys"), ExternalKeys.PrintUniqueKeys(ctx.Keyset)); + File.WriteAllText(Path.Combine(dir, "title.keys"), ExternalKeys.PrintTitleKeys(ctx.Keyset)); + } } private static void ProcessKeygen(Context ctx)