b54aded2ea
Enhanced the MainForm UI by adding labels for contributor credits and a link to the repository. Updated the license generation status to display the license file path. Also added Newtonsoft.Json 13.0.3 as a dependency and cleaned up unused Properties resources from the project file. Co-Authored-By: YurZoRE <68684104+RE0x0@users.noreply.github.com>
123 lines
4.9 KiB
C#
123 lines
4.9 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
|
|
namespace BunifuLicenseGenerator
|
|
{
|
|
public partial class MainForm : Form
|
|
{
|
|
public MainForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private void MainForm_Load( object sender, EventArgs e )
|
|
{
|
|
txtHWID.Text = Hardware.GetUniqueID();
|
|
cmbProduct.SelectedIndex = 0;
|
|
}
|
|
|
|
private void btnGenerate_Click( object sender, EventArgs e )
|
|
{
|
|
try
|
|
{
|
|
var productType = (LicenseGenerator.ProductType)cmbProduct.SelectedIndex;
|
|
var licenseKey = txtLicenseKey.Text.Trim();
|
|
var name = txtName.Text.Trim();
|
|
var email = txtEmail.Text.Trim();
|
|
var isEnterprise = chkEnterprise.Checked;
|
|
|
|
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(email))
|
|
{
|
|
MessageBox.Show("Please enter both name and email.");
|
|
return;
|
|
}
|
|
|
|
string existingLicense = null;
|
|
|
|
// Check file
|
|
string licenseFilePath = Path.Combine(
|
|
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
|
$"Bunifu Technologies/{productType}",
|
|
"License.lic"
|
|
);
|
|
|
|
if (File.Exists(licenseFilePath))
|
|
{
|
|
string encryptedData = File.ReadAllText(licenseFilePath);
|
|
existingLicense = Cryptography.Decrypt(encryptedData);
|
|
}
|
|
|
|
// Check registry
|
|
else
|
|
{
|
|
using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey($@"Software\Bunifu Technologies\{productType}"))
|
|
{
|
|
if (key != null)
|
|
{
|
|
var encryptedData = key.GetValue("CLI") as string;
|
|
if (!string.IsNullOrEmpty(encryptedData))
|
|
{
|
|
existingLicense = Cryptography.Decrypt(encryptedData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(existingLicense))
|
|
{
|
|
var existingRecord = JsonConvert.DeserializeObject<LicenseGenerator.LicenseRecord>(existingLicense);
|
|
MessageBox.Show($"Existing license found. No new license was generated.");
|
|
return;
|
|
}
|
|
|
|
labelStatus.Text = "Generating license...";
|
|
Application.DoEvents();
|
|
|
|
string licenseJson = LicenseGenerator.GenerateLicense(productType, email, name, licenseKey, isEnterprise);
|
|
string encryptedLicense = Cryptography.Encrypt(licenseJson);
|
|
|
|
LicenseGenerator.SaveLicenseToFile(encryptedLicense, productType);
|
|
LicenseGenerator.SaveLicenseToRegistry(encryptedLicense, productType);
|
|
string programDataPath = Path.Combine(
|
|
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
|
"Bunifu Technologies"
|
|
);
|
|
|
|
string productFolder = Path.Combine(programDataPath, productType.ToString());
|
|
Directory.CreateDirectory(productFolder);
|
|
|
|
string _licenseFilePath = Path.Combine(productFolder, "License.lic");
|
|
|
|
labelStatus.Text = "License generated and saved successfully! (" + _licenseFilePath + ")";
|
|
MessageBox.Show("License generated successfully!\n\n" +
|
|
$"Product: {productType}\n" +
|
|
$"HWID: {Hardware.GetUniqueID()}\n" +
|
|
$"Email: {email}\n" +
|
|
$"License Type: {(isEnterprise ? "Enterprise" : "Premium")}",
|
|
"Success",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
labelStatus.Text = "Error generating license!";
|
|
MessageBox.Show("Error: " + ex.Message, "Error",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
{
|
|
System.Diagnostics.Process.Start("https://github.com/t0int1337/BunifuUiCrack");
|
|
|
|
}
|
|
|
|
private void label2_Click(object sender, EventArgs e)
|
|
{
|
|
System.Diagnostics.Process.Start("https://github.com/t0int1337/BunifuUiCrack/graphs/contributors");
|
|
}
|
|
}
|
|
}
|