diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/Moero/DownhillNight/PKDDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/Moero/DownhillNight/PKDDataFormat.cs index ff379811..1ea735ee 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/Moero/DownhillNight/PKDDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/Moero/DownhillNight/PKDDataFormat.cs @@ -18,10 +18,19 @@ namespace UniversalEditor.DataFormats.FileSystem.Moero.DownhillNight _dfr = base.MakeReference(); _dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All); _dfr.Filters.Add("Moero Downhill Night PKD archive", new byte?[][] { new byte?[] { (byte)'P', (byte)'A', (byte)'C', (byte)'K' } }, new string[] { "*.pkd" } ); + + _dfr.ImportOptions.Add(new CustomOptionNumber("EncryptionKey", "Encryption &key:", 0xC5, 0, 255)); + _dfr.ExportOptions.Add(new CustomOptionNumber("EncryptionKey", "Encryption &key:", 0xC5, 0, 255)); } return _dfr; } + private byte mvarEncryptionKey = 0xC5; + /// + /// The single-byte encryption key XORed with the file data. + /// + public byte EncryptionKey { get { return mvarEncryptionKey; } set { mvarEncryptionKey = value; } } + protected override void LoadInternal(ref ObjectModel objectModel) { FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel); @@ -34,7 +43,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Moero.DownhillNight byte[] encryptedData = br.ReadToEnd(); for (int i = 0; i < encryptedData.Length; i++) { - encryptedData[i] = (byte)(encryptedData[i] ^ 0xC5); + encryptedData[i] = (byte)(encryptedData[i] ^ mvarEncryptionKey); } br = new IO.Reader(new MemoryAccessor(encryptedData)); @@ -103,7 +112,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Moero.DownhillNight byte[] data = ma.ToArray(); for (int i = 0; i < data.Length; i++) { - data[i] = (byte)(data[i] ^ 0xC5); + data[i] = (byte)(data[i] ^ mvarEncryptionKey); } bw.WriteBytes(data); bw.Flush();