Over a million developers have joined DZone.

C#: One-line SHA1 Or MD5 Crypto-hash

·
Perform a hash and base64-encode:


// SHA1 hash:
string h1 = Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes("one two")));

// MD5 hash:
string h2 = Convert.ToBase64String(new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes("one two")))
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}