纽威
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
864 B

1 year ago
  1. using System.Configuration;
  2. using System.Web;
  3. namespace NFine.Code
  4. {
  5. public sealed class Licence
  6. {
  7. public static bool IsLicence(string key)
  8. {
  9. string host = HttpContext.Current.Request.Url.Host.ToLower();
  10. if (host.Equals("localhost"))
  11. return true;
  12. string licence = ConfigurationManager.AppSettings["LicenceKey"];
  13. if (licence != null && licence == Md5.md5(key, 32))
  14. return true;
  15. return false;
  16. }
  17. public static string GetLicence()
  18. {
  19. var licence = Configs.GetValue("LicenceKey");
  20. if (string.IsNullOrEmpty(licence))
  21. {
  22. licence = Common.GuId();
  23. Configs.SetValue("LicenceKey", licence);
  24. }
  25. return Md5.md5(licence, 32);
  26. }
  27. }
  28. }