Calculate MD5 hash


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.