Open-source. net license tool, EasyLicense !, Licenseeasylicense
Introduction:
In the past, I often used to check whether there is a software that helps with authorization. It can easily create a license and easily verify the license.
This is a very common and public function, but I have not found a suitable open-source software. Most open-source software is complicated and has many features I don't need.
So I created this project, hoping to simplify the authorization process.
Code:
Easy License is very Easy to use. To verify a software, you need to take the following three steps.
1: CreatePublic/privateKey.
if (File.Exists("privateKey.xml") || File.Exists("publicKey.xml")){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("privateKey.xml", privateKey);File.WriteAllText("publicKey.xml", publicKey);MessageBox.Show("The Key is created, please backup it.");
2: UsePrivateKey to create a license
if (!File.Exists("privateKey.xml")){MessageBox.Show("Please create a license key first");return;} var privateKey = File.ReadAllText(@"privateKey.xml");var generator = new LicenseGenerator(privateKey); var dictionary = new Dictionary<string, string>(); // generate the licensevar license = generator.Generate("EasyLicense", Guid.NewGuid(), DateTime.UtcNow.AddYears(1), dictionary,LicenseType.Standard);txtLicense.Text = license;File.WriteAllText("license.lic", license);
3: UsePublicKey to validate the license
private static void ValidateLicense(){if (!File.Exists("publicKey.xml")){MessageBox.Show("Please create a license key first");return;}var publicKey = File.ReadAllText(@"publicKey.xml"); var validator = new LicenseValidator(publicKey, @"license.lic"); try{validator.AssertValidLicense();}catch (Exception ex){Console.WriteLine(ex.Message);}
There is an internal EasyLicense namedLicenseToolTool, you can download the source code, run, to see how it creates a Key, create Licens and verify License.
The system also has a Demo project to help you.
Git. Please add a star.
Https://github.com/EasyHelper/EasyLicense
Http://git.oschina.net/EasyHelper/EasyLicense