纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
840 B

3 years ago
  1. namespace NFine.Code
  2. {
  3. /// <summary>
  4. /// MD5加密
  5. /// </summary>
  6. public class Md5
  7. {
  8. /// <summary>
  9. /// MD5加密
  10. /// </summary>
  11. /// <param name="str">加密字符</param>
  12. /// <param name="code">加密位数16/32</param>
  13. /// <returns></returns>
  14. public static string md5(string str, int code)
  15. {
  16. string strEncrypt = string.Empty;
  17. if (code == 16)
  18. {
  19. strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").Substring(8, 16);
  20. }
  21. if (code == 32)
  22. {
  23. strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
  24. }
  25. return strEncrypt;
  26. }
  27. }
  28. }