Ejemplo n.º 1
0
        private static LicenseData GetLicenseData()
        {
            LicenseData licData = null;

            try
            {
                if (IsLicenseFileExist())
                {
                    string sData = System.IO.File.ReadAllText(_sLicFile);
                    string uid   = GetUID();
                    byte[] key_uid, vi_uid;
                    GenerateAESKeyVI(uid, out key_uid, out vi_uid);
                    string decryptedData = Crytographic.DecryptAesManaged(sData, key_uid, vi_uid);

                    licData = Newtonsoft.Json.JsonConvert.DeserializeObject <LicenseData>(decryptedData, new Newtonsoft.Json.JsonSerializerSettings()
                    {
                        DateParseHandling = Newtonsoft.Json.DateParseHandling.None
                    });
                }
            }
            catch
            { throw; }

            return(licData);
        }
Ejemplo n.º 2
0
        public static bool Generate_NewLicenseFile()
        {
            bool bretval = false;

            try
            {
                var sLicStructure = new LicenseData();
                sLicStructure.InitDate = System.DateTime.Today;
                sLicStructure.LastRun  = System.DateTime.Today;
                sLicStructure.EndDate  = System.DateTime.Today.AddMonths(6).AddHours(23).AddMinutes(59).AddSeconds(59);
                UpdateLicenseFile(sLicStructure);

                /*
                 * byte[] key_uid, vi_uid;
                 * GenerateAESKeyVI(uid, out key_uid, out vi_uid);
                 *
                 * var licDataJson= Newtonsoft.Json.JsonConvert.SerializeObject(sLicStructure);
                 * string encryptedData = Crytographic.EncryptAesManaged(licDataJson, key_uid, vi_uid);
                 *
                 * System.IO.File.WriteAllText(_sLicFile, encryptedData);
                 * string decryptedData = Crytographic.DecryptAesManaged(encryptedData, key_uid, vi_uid);
                 * var libdata = Newtonsoft.Json.JsonConvert.DeserializeObject(decryptedData);*/
            }
            catch (Exception ex)
            {
            }

            return(bretval);
        }
Ejemplo n.º 3
0
        private static void UpdateLicenseFile(LicenseData licData)
        {
            try
            {
                if (licData != null)
                {
                    if (!System.IO.Directory.Exists(_sLicPath))
                    {
                        System.IO.Directory.CreateDirectory(_sLicPath);
                    }



                    var licDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(licData);

                    string uid = GetUID();
                    byte[] key_uid, vi_uid;
                    GenerateAESKeyVI(uid, out key_uid, out vi_uid);

                    string encryptedData = Crytographic.EncryptAesManaged(licDataJson, key_uid, vi_uid);

                    System.IO.File.WriteAllText(_sLicFile, encryptedData);
                }
            }
            catch
            { throw; }
        }