public static bool IsLicenseVerify(string lic) { Debug.Assert(!string.IsNullOrEmpty(lic)); try { var mask = lic.Substring(0, 8); if (mask.StartsWith("d")) // demo { int seconds = Convert.ToInt32(mask.Substring(2)); // seconds return(Global.Config.InstallTime < DateTime.Now.AddSeconds(-seconds)); } else if (mask.StartsWith("s")) // single { var mid = new bfbd.Common.License.MachineInfo().GetMachineId(bfbd.Common.License.HardwareType.Driver); var md5 = bfbd.Common.Encryption.MD5(mid, "bfbd"); ulong val = Convert.ToUInt32(md5.Substring(0, 8), 16); val ^= Convert.ToUInt32(md5.Substring(8, 8), 16); val ^= Convert.ToUInt32(md5.Substring(16, 8), 16); val ^= Convert.ToUInt32(md5.Substring(24, 8), 16); return(mask.Substring(1) == string.Format("{0:X8}", val).Substring(1)); } else { return(false); } } catch (Exception ex) { TraceLogger.Instance.WriteException(ex); return(false); } }
public bool IsValid() { switch (License) { case LicenseType.Demo: { return(CreateTime < DateTime.Now && DateTime.Now < ExpireTime); } case LicenseType.Professional: { // check MachineId to local driver. string mid = new MachineInfo().GetMachineId(HardwareType.Driver); if (MachineId == mid) { return(CreateTime < DateTime.Now && DateTime.Now < ExpireTime); } else { return(false); } } case LicenseType.Enterprise: { // check MachineId to server mac. //if (string.IsNullOrEmpty(serverHost)) //serverHost = System.Net.Dns.GetHostName(); //var entry = System.Net.Dns.GetHostEntry(serverHost); //]Iphlpapi.dll] //DWORD SendARP( // _In_ IPAddr DestIP, // _In_ IPAddr SrcIP, // _Out_ PULONG pMacAddr, // _Inout_ PULONG PhyAddrLen //); throw new NotImplementedException(); } default: return(false); } }