Beispiel #1
0
        public static void WriteApiFileKey(LicenseSpringLocalKey localKey, bool isDevMachine = false)
        {
            string saveFilePath = string.Empty;

            if (isDevMachine)
            {
                saveFilePath = Path.Combine(developerFolderPath, $"{UnityEngine.Application.productName}.bin");
            }
            else
            {
                saveFilePath = Path.Combine(standardFolderPath, $"{UnityEngine.Application.productName}.bin");
            }

            var jsonRep = JsonConvert.SerializeObject(localKey);

            //FINISH :sodium implementation.
            var key    = Sodium.SecretBox.GenerateKey();
            var noonce = Sodium.SecretBox.GenerateNonce();
            var cipher = Sodium.SecretBox.Create(jsonRep, noonce, key);

            var union = new byte[key.Length + noonce.Length + cipher.Length];

            key.CopyTo(union, 0);
            noonce.CopyTo(union, key.Length);
            cipher.CopyTo(union, key.Length + noonce.Length);

            using (MemoryStream msCipher = new MemoryStream(union))
            {
                using (FileStream fs = new FileStream(saveFilePath, FileMode.OpenOrCreate))
                {
                    msCipher.CopyTo(fs);
                }
            }
        }
Beispiel #2
0
    private void OnbtnCreateDevClick()
    {
        LicenseSpringLocalKey localKey = new LicenseSpringLocalKey {
            ApiKey             = _txtInputKey.text,
            ApplicationName    = _txtProductName.text,
            IsDevelopment      = true,
            ApplicationVersion = _txtProductVersion.text,
            ProductCode        = _txtProductCode.text,
            SharedKey          = _txtInputSharedKey.text
        };

        LicenseApiConfigurationHelper.WriteApiFileKey(localKey, isDevMachine: true);
    }