Changed to SHA512
This commit is contained in:
parent
2c812dbb53
commit
4e87ceb84f
2 changed files with 9 additions and 16 deletions
|
|
@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.3.0.0630")]
|
[assembly: AssemblyVersion("2.3.0.0701")]
|
||||||
[assembly: AssemblyFileVersion("2.3.0.0630")]
|
[assembly: AssemblyFileVersion("2.3.0.0701")]
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ using System.Text;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
@ -634,16 +635,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
return IP4Address;
|
return IP4Address;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Returns a byte array for a given string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="str">string str</param>
|
|
||||||
/// <returns>byte[] string</returns>
|
|
||||||
public static byte[] StrToByteArray(string str)
|
|
||||||
{
|
|
||||||
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
|
|
||||||
return encoding.GetBytes(str);
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a Sha256 string for a given string
|
/// Returns a Sha256 string for a given string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -651,10 +643,11 @@ namespace TShockAPI
|
||||||
/// <returns>string sha256</returns>
|
/// <returns>string sha256</returns>
|
||||||
public static string HashPassword(string password)
|
public static string HashPassword(string password)
|
||||||
{
|
{
|
||||||
Encoding enc = System.Text.Encoding.UTF8;
|
using (var sha = new SHA512CryptoServiceProvider())
|
||||||
byte[] buffer = enc.GetBytes(password);
|
{
|
||||||
SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider();
|
var bytes = sha.ComputeHash(Encoding.ASCII.GetBytes(password));
|
||||||
return BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "");
|
return bytes.Aggregate("", (s, b) => s + b.ToString("X2"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue