working new aes manager

This commit is contained in:
Asval
2019-06-14 02:21:37 +02:00
parent 458f994ded
commit dcacef3969
8 changed files with 122 additions and 89 deletions

View File

@@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Xml.Serialization;
namespace FModel
{
static class AESManager
{
/*public static List<AESEntry> AESEntries { get; set; }
private static XmlSerializer serializer = new XmlSerializer(typeof(List<AESEntry>));
public static void serialize(string data)
{
ConfigurationUserLevel level = ConfigurationUserLevel.PerUserRoamingAndLocal;
Configuration configuration = ConfigurationManager.OpenExeConfiguration(level);
string configurationFilePath = configuration.FilePath.Substring(0, configuration.FilePath.LastIndexOf("\\"));
AESEntries.Add(new AESEntry()
{
theKey = data
});
string path = configurationFilePath + "\\AESManager.xml";
Directory.CreateDirectory(Path.GetDirectoryName(path));
using (var fileStream = new FileStream(path, FileMode.Create))
{
serializer.Serialize(fileStream, AESEntries);
}
}
public static string[] deserialize()
{
ConfigurationUserLevel level = ConfigurationUserLevel.PerUserRoamingAndLocal;
Configuration configuration = ConfigurationManager.OpenExeConfiguration(level);
string configurationFilePath = configuration.FilePath.Substring(0, configuration.FilePath.LastIndexOf("\\"));
string path = configurationFilePath + "\\AESManager.xml";
List<AESEntry> outputList;
using (var fileStream = new FileStream(path, FileMode.Open))
{
outputList = (List<AESEntry>)serializer.Deserialize(fileStream);
}
string[] toReturn = new string[outputList.Count];
for (int i = 0; i < toReturn.Length; i++)
{
toReturn[i] = outputList[i].theKey;
}
return toReturn;
}*/
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Xml.Serialization;
namespace FModel
{
static class DynamicKeysManager
{
public static List<AESEntry> AESEntries { get; set; }
private static XmlSerializer serializer = new XmlSerializer(typeof(List<AESEntry>));
private static string path = Properties.Settings.Default.ExtractOutput + "\\AESManager.xml";
public static void serialize(string key, string pak)
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
AESEntries.Add(new AESEntry()
{
theKey = key,
thePak = pak
});
using (var fileStream = new FileStream(path, FileMode.Create))
{
serializer.Serialize(fileStream, AESEntries);
}
}
public static void deserialize()
{
if (File.Exists(path))
{
List<AESEntry> outputList;
using (var fileStream = new FileStream(path, FileMode.Open))
{
outputList = (List<AESEntry>)serializer.Deserialize(fileStream);
}
AESEntries = outputList;
}
}
}
}

View File

@@ -13,6 +13,7 @@ namespace FModel
{
public static PakAsset MyAsset;
public static PakExtractor MyExtractor;
public static string MyKey;
public static string[] myArray { get; set; }
private static string currentPakToCheck { get; set; }
@@ -72,7 +73,7 @@ namespace FModel
{
if (currentPak != currentPakToCheck || myArray == null)
{
MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + currentPak, Settings.Default.AESKey);
MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + currentPak, MyKey);
myArray = MyExtractor.GetFileList().ToArray();
}

View File

@@ -102,4 +102,20 @@ namespace FModel
throw new NotImplementedException();
}
}
public struct AESEntry : IEquatable<AESEntry>
{
internal AESEntry(string myPak, string myKey)
{
thePak = myPak;
theKey = myKey;
}
public string thePak { get; set; }
public string theKey { get; set; }
bool IEquatable<AESEntry>.Equals(AESEntry other)
{
throw new NotImplementedException();
}
}
}