Command_MD5.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Text;
  15. namespace iNethinkCMS.Command
  16. {
  17. public class Command_MD5
  18. {
  19. public static string md5(string str)
  20. {
  21. System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
  22. byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str);
  23. bytes = md5.ComputeHash(bytes);
  24. md5.Clear();
  25. string ret = "";
  26. for (int i = 0; i < bytes.Length; i++)
  27. {
  28. ret += Convert.ToString(bytes[i], 16).PadLeft(2, '0');
  29. }
  30. return ret.PadLeft(32, '0');
  31. }
  32. }
  33. }