mirror of
https://github.com/4sval/FModel.git
synced 2026-09-25 02:29:21 -05:00
working new aes manager
This commit is contained in:
@@ -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;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
44
FModel/Methods/AESManager/DynamicKeysManager.cs
Normal file
44
FModel/Methods/AESManager/DynamicKeysManager.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user