Exemple #1
0
        public bool CheckLicense()
        {
            string _strFileName = Directory.GetCurrentDirectory() + @"\key.txt";

            string[] lines    = File.ReadAllLines(_strFileName);
            string   _licence = lines[0].ToString().Trim();

            String MAC = NetworkInterface
                         .GetAllNetworkInterfaces()
                         .Where(nic => nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
                         .Select(nic => nic.GetPhysicalAddress().ToString())
                         .FirstOrDefault();

            string tenMayTinh = Environment.MachineName.ToString();
            string heDieuHanh = Environment.OSVersion.ToString();


            string _key = "vietnam" + tenMayTinh + "_ncp." + heDieuHanh;

            using (MD5 md5Hash = MD5.Create())
            {
                string hash = LicenceHelper.GetMd5Hash(md5Hash, _key);
                hash = LicenceHelper.GetMd5Hash(md5Hash, hash + "_");

                if (_licence == hash)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #2
0
 public string GetLicense(string key)
 {
     using (MD5 md5Hash = MD5.Create())
     {
         string hash = LicenceHelper.GetMd5Hash(md5Hash, key);
         hash = LicenceHelper.GetMd5Hash(md5Hash, hash + "_");
         hash = LicenceHelper.GetMd5Hash(md5Hash, "." + hash + ",");
         return(hash);
     }
 }
Exemple #3
0
        public void GetLicense()
        {
            String MAC = NetworkInterface
                         .GetAllNetworkInterfaces()
                         .Where(nic => nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
                         .Select(nic => nic.GetPhysicalAddress().ToString())
                         .FirstOrDefault();

            string tenMayTinh = Environment.MachineName.ToString();
            string heDieuHanh = Environment.OSVersion.ToString();


            string _key = "vietnam" + tenMayTinh + "_ncp." + heDieuHanh;

            using (MD5 md5Hash = MD5.Create())
            {
                string hash = LicenceHelper.GetMd5Hash(md5Hash, _key);
                hash = LicenceHelper.GetMd5Hash(md5Hash, hash + "_");

                string[] lines        = { hash };
                string   _strFileName = Directory.GetCurrentDirectory() + @"\key.txt";
                System.IO.File.WriteAllLines(_strFileName, lines);
            }
        }