diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs
index c43d821b..103c7cd8 100644
--- a/TShockAPI/ConfigFile.cs
+++ b/TShockAPI/ConfigFile.cs
@@ -107,7 +107,7 @@ namespace TShockAPI
public bool DisableSpewLogs = true;
///
- /// Valid types are "sha512", "sha256", "md5"
+ /// Valid types are "sha512", "sha256", "md5", append with "-xp" for the xp supported algorithms
///
public string HashAlgorithm = "sha512";
diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs
index d57eb261..5d67da17 100644
--- a/TShockAPI/Properties/AssemblyInfo.cs
+++ b/TShockAPI/Properties/AssemblyInfo.cs
@@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.2.4.0809")]
-[assembly: AssemblyFileVersion("3.2.4.0809")]
+[assembly: AssemblyVersion("3.2.5.0810")]
+[assembly: AssemblyFileVersion("3.2.5.0810")]
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index a3e9b07a..d74e85ef 100644
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -448,7 +448,7 @@ namespace TShockAPI
private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
{
- if (e.Handled)
+ if (e.Handled)
return;
var tsplr = Players[msg.whoAmI];
@@ -560,7 +560,7 @@ namespace TShockAPI
private void GetData(GetDataEventArgs e)
{
- if (e.Handled)
+ if (e.Handled)
return;
PacketTypes type = e.MsgID;
@@ -732,8 +732,8 @@ namespace TShockAPI
public static bool HackedHealth(TSPlayer player)
{
- return (player.TPlayer.statManaMax > 200) ||
- (player.TPlayer.statMana > 200) ||
+ return (player.TPlayer.statManaMax > 400) ||
+ (player.TPlayer.statMana > 400) ||
(player.TPlayer.statLifeMax > 400) ||
(player.TPlayer.statLife > 400);
}
@@ -759,22 +759,7 @@ namespace TShockAPI
RconHandler.Password = file.RconPassword;
RconHandler.ListenPort = file.RconPort;
- Type hash;
- if (Tools.HashTypes.TryGetValue(file.HashAlgorithm, out hash))
- {
- lock (Tools.HashAlgo)
- {
- if (!Tools.HashAlgo.GetType().Equals(hash))
- {
- Tools.HashAlgo.Dispose();
- Tools.HashAlgo = (HashAlgorithm)Activator.CreateInstance(Tools.HashTypes[file.HashAlgorithm]);
- }
- }
- }
- else
- {
- Log.ConsoleError("Invalid or not supported hashing algorithm: " + file.HashAlgorithm);
- }
+ Tools.HashAlgo = file.HashAlgorithm;
}
}
}
\ No newline at end of file
diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs
index 58eb74d2..a79e5ce7 100755
--- a/TShockAPI/Tools.cs
+++ b/TShockAPI/Tools.cs
@@ -438,15 +438,15 @@ namespace TShockAPI
{
string possibleColor = foo.Substring(0, 13);
foo = foo.Remove(0, 13);
- float[] pC = {0, 0, 0};
+ float[] pC = { 0, 0, 0 };
possibleColor = possibleColor.Replace("%", "");
string[] pCc = possibleColor.Split(',');
if (pCc.Length == 3)
{
try
{
- player.SendMessage(foo, (byte) Convert.ToInt32(pCc[0]), (byte) Convert.ToInt32(pCc[1]),
- (byte) Convert.ToInt32(pCc[2]));
+ player.SendMessage(foo, (byte)Convert.ToInt32(pCc[0]), (byte)Convert.ToInt32(pCc[1]),
+ (byte)Convert.ToInt32(pCc[2]));
continue;
}
catch (Exception e)
@@ -489,13 +489,16 @@ namespace TShockAPI
return ip != null ? ip.ToString() : "";
}
- public static HashAlgorithm HashAlgo = new MD5Cng();
+ public static string HashAlgo = "md5";
- public static readonly Dictionary HashTypes = new Dictionary
- {
- {"sha512", typeof(SHA512Managed)},
- {"sha256", typeof(SHA256Managed)},
- {"md5", typeof(MD5Cng)},
+ public static readonly Dictionary> HashTypes = new Dictionary>
+ {
+ {"sha512", () => new SHA512Managed()},
+ {"sha256", () => new SHA256Managed()},
+ {"md5", () => new MD5Cng()},
+ {"sha512-xp", () => SHA512.Create()},
+ {"sha256-xp", () => SHA256.Create()},
+ {"md5-xp", () => MD5.Create()},
};
///
@@ -507,8 +510,16 @@ namespace TShockAPI
{
if (string.IsNullOrEmpty(password) || password == "non-existant password")
return "non-existant password";
- var bytes = HashAlgo.ComputeHash(Encoding.ASCII.GetBytes(password));
- return bytes.Aggregate("", (s, b) => s + b.ToString("X2"));
+
+ Func func;
+ if (!HashTypes.TryGetValue(HashAlgo.ToLower(), out func))
+ throw new NotSupportedException("Hashing algorithm {0} is not supported".SFormat(HashAlgo.ToLower()));
+
+ using (var hash = func())
+ {
+ var bytes = hash.ComputeHash(Encoding.ASCII.GetBytes(password));
+ return bytes.Aggregate("", (s, b) => s + b.ToString("X2"));
+ }
}
///