Skip to content

Instantly share code, notes, and snippets.

@darrenkopp
Created May 5, 2010 21:38
Show Gist options
  • Save darrenkopp/391476 to your computer and use it in GitHub Desktop.
Save darrenkopp/391476 to your computer and use it in GitHub Desktop.
public class HashProvider
{
readonly SHA1Managed Hasher;
public HashProvider()
{
this.Hasher = new SHA1Managed();
}
public string GenerateHash(string data)
{
var originalBytes = Encoding.ASCII.GetBytes(data);
var hashedBytes = Hasher.ComputeHash(originalBytes);
var builder = new StringBuilder();
foreach (Byte hashed in hashedBytes)
builder.AppendFormat("{0:x2}", hashed);
return builder.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment