Пример #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);
        }
Пример #2
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; }
        }