Skip to content

Instantly share code, notes, and snippets.

@madd0
Created November 15, 2011 09:06
Show Gist options
  • Select an option

  • Save madd0/1366511 to your computer and use it in GitHub Desktop.

Select an option

Save madd0/1366511 to your computer and use it in GitHub Desktop.

Revisions

  1. madd0 revised this gist Nov 16, 2011. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions md5.cs
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,11 @@
    string toHash = "my string to hash";
    string hashed;

    using (MD5 md5 = MD5.Create())
    public static string MD5Hash(string toHash)
    {
    hashed = string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(toHash)).Select(b => b.ToString("x2")));
    string hashed;

    using (MD5 md5 = MD5.Create())
    {
    hashed = string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(toHash)).Select(b => b.ToString("x2")));
    }

    return hashed;
    }
  2. madd0 created this gist Nov 15, 2011.
    7 changes: 7 additions & 0 deletions md5.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    string toHash = "my string to hash";
    string hashed;

    using (MD5 md5 = MD5.Create())
    {
    hashed = string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(toHash)).Select(b => b.ToString("x2")));
    }