Skip to main content

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

Comments

Nice function Beebe.
Lincoln Madison said…
This comment has been removed by a blog administrator.

Popular posts from this blog

Home Office Remodel Phase II: Pt 2 Electrical

Well, the electrical portion is all done. Lessons learned. Let's see, Always use junction boxes when tieing lines together. Be sure to buy extra wire nuts, you are bound to lose a box until you a finished when it magically reappears, same goes for electrical tape, two rolls minimum even if you only need 6 inches. Well here is the part that you have all been waiting for I know. Be sure to click the images for a better picture. Here is what is left of that tangled mess between the floor joists. Here is the outlet for under the desk. So stay tuned, more DIY is coming soon. The next section is Phase III: Phone