2015-03-20 13:45:58 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-20 18:09:08 +00:00
|
|
|
|
StringBuilder hash = new StringBuilder();
|
|
|
|
|
|
2015-03-20 13:45:58 +00:00
|
|
|
|
foreach (byte _byte in data)
|
2015-03-20 18:09:08 +00:00
|
|
|
|
hash.Append(_byte.ToString("X2"));
|
2015-03-20 13:45:58 +00:00
|
|
|
|
|
2015-03-20 18:09:08 +00:00
|
|
|
|
return hash.ToString().ToUpper();
|
2015-03-20 13:45:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-21 18:27:52 +00:00
|
|
|
|
}
|