Posted By

Steiner on 02/14/10


Tagged

method md5 extention Encryption


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

emregulcan
hinesnetwork
khouser
jalalx


MD5 Encryption


 / Published in: C#
 

  1. namespace [[AppName]].Helpers
  2. {
  3. static public class Helper
  4. {
  5.  
  6. /// <summary>
  7. /// Returns string into an MD5 encrypted 32 character string
  8. /// </summary>
  9. /// <param name="originalText">Extended Method, the original text value</param>
  10. /// <returns>MD5 encrypted string</returns>
  11. static public string ToEncodeMD5(this string originalText)
  12. {
  13. System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
  14. byte[] data = System.Text.Encoding.ASCII.GetBytes(originalText);
  15. data = x.ComputeHash(data);
  16. string ret = "";
  17. for (int i = 0; i < data.Length; i++)
  18. ret += data[i].ToString("x2").ToLower();
  19. return ret;
  20. }
  21. }
  22. }

Report this snippet  

You need to login to post a comment.