From 9a619186fd996c3339d907a0fd1d08a82483a980 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sun, 8 May 2022 19:56:59 -0600 Subject: [PATCH] If keeping aaxc, write aaxc key to file --- AaxDecrypter/AudiobookDownloadBase.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/AaxDecrypter/AudiobookDownloadBase.cs b/AaxDecrypter/AudiobookDownloadBase.cs index c825bf4e..ef16f7d5 100644 --- a/AaxDecrypter/AudiobookDownloadBase.cs +++ b/AaxDecrypter/AudiobookDownloadBase.cs @@ -122,11 +122,20 @@ namespace AaxDecrypter { FileUtility.SaferDelete(jsonDownloadState); - if (DownloadOptions.RetainEncryptedFile) + if (DownloadOptions.AudibleKey is not null && + DownloadOptions.AudibleIV is not null && + DownloadOptions.RetainEncryptedFile) { string aaxPath = Path.ChangeExtension(TempFilePath, ".aax"); FileUtility.SaferMove(TempFilePath, aaxPath); + + //Write aax decryption key + string keyPath = Path.ChangeExtension(aaxPath, ".key"); + FileUtility.SaferDelete(keyPath); + File.WriteAllText(keyPath, $"Key={DownloadOptions.AudibleKey}\r\nIV={DownloadOptions.AudibleIV}"); + OnFileCreated(aaxPath); + OnFileCreated(keyPath); } else FileUtility.SaferDelete(TempFilePath);