diff --git a/MelonLoader/Lemons/Cryptography/LemonMD5.cs b/MelonLoader/Lemons/Cryptography/LemonMD5.cs index 5e0b37ff8..475b655cd 100644 --- a/MelonLoader/Lemons/Cryptography/LemonMD5.cs +++ b/MelonLoader/Lemons/Cryptography/LemonMD5.cs @@ -6,14 +6,19 @@ namespace MelonLoader.Lemons.Cryptography public class LemonMD5 { private HashAlgorithm algorithm; + private static LemonMD5 static_algorithm = new(); - public LemonMD5() + public LemonMD5() { algorithm = (HashAlgorithm)CryptoConfig.CreateFromName("System.Security.Cryptography.MD5"); algorithm.SetHashSizeValue(256); } - public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); + public static byte[] ComputeMD5Hash(byte[] buffer) => static_algorithm.ComputeHash(buffer); + public static byte[] ComputeMD5Hash(byte[] buffer, int offset, int count) => static_algorithm.ComputeHash(buffer, offset, count); + public static byte[] ComputeMD5Hash(Stream inputStream) => static_algorithm.ComputeHash(inputStream); + + public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); public byte[] ComputeHash(byte[] buffer, int offset, int count) => algorithm.ComputeHash(buffer, offset, count); public byte[] ComputeHash(Stream inputStream) => algorithm.ComputeHash(inputStream); } diff --git a/MelonLoader/Lemons/Cryptography/LemonSHA256.cs b/MelonLoader/Lemons/Cryptography/LemonSHA256.cs index 91be6a6eb..be2ab6115 100644 --- a/MelonLoader/Lemons/Cryptography/LemonSHA256.cs +++ b/MelonLoader/Lemons/Cryptography/LemonSHA256.cs @@ -7,14 +7,19 @@ namespace MelonLoader.Lemons.Cryptography public class LemonSHA256 { private HashAlgorithm algorithm; + private static LemonSHA256 static_algorithm = new(); - public LemonSHA256() + public LemonSHA256() { algorithm = (HashAlgorithm)CryptoConfig.CreateFromName("System.Security.Cryptography.SHA256"); algorithm.SetHashSizeValue(256); } - public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); + public static byte[] ComputeSHA256Hash(byte[] buffer) => static_algorithm.ComputeHash(buffer); + public static byte[] ComputeSHA256Hash(byte[] buffer, int offset, int count) => static_algorithm.ComputeHash(buffer, offset, count); + public static byte[] ComputeSHA256Hash(Stream inputStream) => static_algorithm.ComputeHash(inputStream); + + public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); public byte[] ComputeHash(byte[] buffer, int offset, int count) => algorithm.ComputeHash(buffer, offset, count); public byte[] ComputeHash(Stream inputStream) => algorithm.ComputeHash(inputStream); } diff --git a/MelonLoader/Lemons/Cryptography/LemonSHA512.cs b/MelonLoader/Lemons/Cryptography/LemonSHA512.cs index 6bec548bb..fac019107 100644 --- a/MelonLoader/Lemons/Cryptography/LemonSHA512.cs +++ b/MelonLoader/Lemons/Cryptography/LemonSHA512.cs @@ -6,12 +6,17 @@ namespace MelonLoader.Lemons.Cryptography public class LemonSHA512 { private HashAlgorithm algorithm; + private static LemonSHA512 static_algorithm = new(); - public LemonSHA512() + public LemonSHA512() { algorithm = (HashAlgorithm)CryptoConfig.CreateFromName("System.Security.Cryptography.SHA512"); algorithm.SetHashSizeValue(512); - } + } + + public static byte[] ComputeSHA512Hash(byte[] buffer) => static_algorithm.ComputeHash(buffer); + public static byte[] ComputeSHA512Hash(byte[] buffer, int offset, int count) => static_algorithm.ComputeHash(buffer, offset, count); + public static byte[] ComputeSHA512Hash(Stream inputStream) => static_algorithm.ComputeHash(inputStream); public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); public byte[] ComputeHash(byte[] buffer, int offset, int count) => algorithm.ComputeHash(buffer, offset, count);