Wednesday, December 29, 2010

Create a SHA1 hash of a string

This function will take a string and return the hashed value
using System.Security.Cryptography;
public static string GetSha1(string value)
{
var data = Encoding.ASCII.GetBytes(value);
var hashData = new SHA1Managed().ComputeHash(data);

var hash = string.Empty;

foreach (var b in hashData)
hash += b.ToString("X2");

return hash;
}

Thanks to Lars-Erik

2 comments:

MD5 Hash Generator said...

Nice function Beebe.

Anonymous said...

Просто хорошая страничка