Files
Quasar/Client/Core/Encryption/SHA256.cs
T
yankejustin b462be3b3a Efficiency increase
String concatenation is exponentially slower than StringBuilder. This
optimization will increase the speed greatly.
2015-03-20 14:09:08 -04:00

26 lines
618 B
C#

using System.Security.Cryptography;
using System.Text;
namespace xClient.Core.Encryption
{
public static class SHA256
{
public static string ComputeHash(string input)
{
byte[] data = Encoding.UTF8.GetBytes(input);
using (SHA256Managed sha = new SHA256Managed())
{
data = sha.ComputeHash(data, 0, data.Length);
}
StringBuilder hash = new StringBuilder();
foreach (byte _byte in data)
hash.Append(_byte.ToString("X2"));
return hash.ToString().ToUpper();
}
}
}