30 lines
805 B
C#
30 lines
805 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace Activizr.Logic.Security
|
|
{
|
|
/// <summary>
|
|
/// Summary description for SHA1.
|
|
/// </summary>
|
|
public class SHA1
|
|
{
|
|
public static string Hash (string input)
|
|
{
|
|
byte[] data = Encoding.GetEncoding(1252).GetBytes(input);
|
|
|
|
System.Security.Cryptography.SHA1 SHA1 = new SHA1CryptoServiceProvider();
|
|
byte[] hash = SHA1.ComputeHash(data);
|
|
|
|
// Write the resulting hash to a string of hex values.
|
|
|
|
var result = new StringBuilder();
|
|
|
|
foreach (byte oneByte in hash)
|
|
{
|
|
result.Append(oneByte.ToString("X02") + " ");
|
|
}
|
|
|
|
return result.ToString().TrimEnd();
|
|
}
|
|
}
|
|
} |