From feb6f370c0a6cac2d02f0706317d3cc39606c9da Mon Sep 17 00:00:00 2001 From: Razmoth <12517189-Razmoth@users.noreply.gitlab.com> Date: Sat, 7 Jan 2023 21:52:15 +0400 Subject: [PATCH] Optimizations. --- AssetStudio/Crypto/BlkUtils.cs | 4 +- AssetStudio/Crypto/MT19937_64.cs | 19 +++--- AssetStudioGUI/App.config | 102 +++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 AssetStudioGUI/App.config diff --git a/AssetStudio/Crypto/BlkUtils.cs b/AssetStudio/Crypto/BlkUtils.cs index 7bf727e..3e2f655 100644 --- a/AssetStudio/Crypto/BlkUtils.cs +++ b/AssetStudio/Crypto/BlkUtils.cs @@ -46,11 +46,11 @@ namespace AssetStudio var keyHigh = BinaryPrimitives.ReadUInt64LittleEndian(key.AsSpan(8, 8)); var seed = keyLow ^ keyHigh ^ keySeed ^ blk.InitSeed; - MT19937_64.Init(seed); + var mt64 = new MT19937_64(seed); var xorpad = new byte[KeySize]; for (int i = 0; i < KeySize; i += 8) { - BinaryPrimitives.WriteUInt64LittleEndian(xorpad.AsSpan(i, 8), MT19937_64.Int64()); + BinaryPrimitives.WriteUInt64LittleEndian(xorpad.AsSpan(i, 8), mt64.Int64()); } return new CryptoStream(reader.BaseStream, xorpad); diff --git a/AssetStudio/Crypto/MT19937_64.cs b/AssetStudio/Crypto/MT19937_64.cs index efa7a1e..cc4c899 100644 --- a/AssetStudio/Crypto/MT19937_64.cs +++ b/AssetStudio/Crypto/MT19937_64.cs @@ -1,6 +1,6 @@ namespace AssetStudio { - public static class MT19937_64 + public class MT19937_64 { private const ulong N = 312; private const ulong M = 156; @@ -8,10 +8,15 @@ private const ulong UPPER_MASK = 0xFFFFFFFF80000000; private const ulong LOWER_MASK = 0X7FFFFFFFUL; - private static readonly ulong[] mt = new ulong[N + 1]; - private static ulong mti = N + 1; + private readonly ulong[] mt = new ulong[N + 1]; + private ulong mti = N + 1; - public static void Init(ulong seed) + public MT19937_64(ulong seed) + { + Init(seed); + } + + public void Init(ulong seed) { mt[0] = seed; for (mti = 1; mti < N; mti++) @@ -20,7 +25,7 @@ } } - public static ulong Int64() + public ulong Int64() { ulong x; ulong[] mag01 = new ulong[2] { 0x0UL, MATRIX_A }; @@ -56,12 +61,12 @@ return x; } - public static long Int63() + public long Int63() { return (long)(Int64() >> 1); } - public static ulong IntN(ulong value) + public ulong IntN(ulong value) { return (ulong)Int63() % value; } diff --git a/AssetStudioGUI/App.config b/AssetStudioGUI/App.config new file mode 100644 index 0000000..bc029f7 --- /dev/null +++ b/AssetStudioGUI/App.config @@ -0,0 +1,102 @@ + + + + +
+ + + + + + False + + + True + + + True + + + True + + + 0 + + + True + + + True + + + True + + + 0.25 + + + True + + + True + + + True + + + 10 + + + 3 + + + 0 + + + 1 + + + True + + + False + + + True + + + False + + + 147 + + + True + + + True + + + False + + + 0 + + + True + + + 0 + + + 0 + + + True + + + True + + + + \ No newline at end of file