Beispiel #1
0
        private void btnGenerateLicenseKey_Click(object sender, RoutedEventArgs e)
        {
            // var assembly = AppDomain.CurrentDomain.BaseDirectory;
            var privateKeyPath = GetWorkDirFile("privateKey.xml");
            var publicKeyPath  = GetWorkDirFile("publicKey.xml");

            if (File.Exists(privateKeyPath) || File.Exists(publicKeyPath))
            {
                var result = MessageBox.Show("The key is existed, override it?", "Warning", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.No)
                {
                    return;
                }
            }

            var privateKey = "";
            var publicKey  = "";

            LicenseGenerator.GenerateLicenseKey(out privateKey, out publicKey);

            File.WriteAllText(privateKeyPath, privateKey);
            File.WriteAllText(publicKeyPath, publicKey);

            MessageBox.Show("The Key is created, please backup it.");
        }
Beispiel #2
0
        private void generateKeys(bool isLoad = false)
        {
            if (File.Exists("privateKey.xml") || File.Exists("publicKey.xml"))
            {
                if (isLoad == false)
                {
                    var result = MessageBox.Show("The key is existed, override it?", "Warning", MessageBoxButtons.YesNo);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            var privateKey = "";
            var publicKey  = "";

            LicenseGenerator.GenerateLicenseKey(out privateKey, out publicKey);

            File.WriteAllText("privateKey.xml", privateKey);
            File.WriteAllText("publicKey.xml", publicKey);

            ResultText.AppendText("The Key is created, please backup it.\n");
        }
Beispiel #3
0
        /// <summary>
        /// 生成key
        /// </summary>
        /// <returns>返回 privatekey</returns>
        private static string GenerateLicenseKey()
        {
            string publicKey  = string.Empty;
            string privateKey = string.Empty;

            LicenseGenerator.GenerateLicenseKey(out privateKey, out publicKey);
            File.WriteAllText(_path_pub, publicKey);

            return(privateKey);
        }