Posted By

Elph on 08/09/08


Tagged

hash md5 criptography


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Calculate MD5 hash


 / Published in: C#
 

  1. // using System;
  2. // using System.Text;
  3. // using System.Security.Cryptography;
  4.  
  5. private string GetHash(string str)
  6. {
  7. MD5 md5 = MD5CryptoServiceProvider.Create();
  8. ASCIIEncoding encoding = new ASCIIEncoding();
  9. StringBuilder sb = new StringBuilder();
  10. byte[] stream = md5.ComputeHash(encoding.GetBytes(str));
  11. for (int i = 0; i < stream.Length; i++)
  12. {
  13. sb.AppendFormat("{0:x2}", stream[i]);
  14. }
  15. return sb.ToString();
  16. }

Report this snippet  

You need to login to post a comment.