private string GenerateSerialFromModel(SerialNumberGenerator serialNumberGenerator)
        {
            var rsaPrivateKeyIdentity = new RsaKeySetIdentity(RSAKeys.PrivateKeys.GetKeyString(), RSAKeys.PublicKeys.GetKeyString());
            var licenseKey            = serialNumberGenerator.GenerateLicenseData(rsaPrivateKeyIdentity);

            return(licenseKey);
        }
Example #2
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (txtSalt.Text.Length == 0)
            {
                MessageBox.Show(this, "Salt can not be empty, please generate a new value", "Missing salt", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (registrationDataModel == null)
            {
                registrationDataModel = new RegistrationDataModel();
            }

            registrationDataModel.Company     = txtCompany.Text;
            registrationDataModel.FirstName   = txtFirstName.Text;
            registrationDataModel.LastName    = txtLastName.Text;
            registrationDataModel.Salt        = txtSalt.Text;
            registrationDataModel.ValidTo     = dateTimePicker.Value;
            registrationDataModel.VersionName = comboVersion.SelectedText;

            serialNumberGenerator.LicenseData.RegistrationData = registrationDataModel;
            serialNumberGenerator.GenerateLicenseData(rsaPrivateKeyIdentity);

            txtSerial.Text = serialNumberGenerator.LicenseData.RegistrationKey;
            ComputeAndSetSaltValue();

            string path = destinationFolder + "\\" + serialNumberGenerator.LicenseData.RegistrationKey;

            CreateFolder(path);
            serialNumberGenerator.CreateLicenseFile(path + "\\license.txt");
        }