Introduced:
In the past I used to like whether there was a software to help the authorization, it can be very simple to create license, and very easy to verify the license.
This is a very common and public function, but I did not find the right open source software, most of the open source software is more complex, and there are too many features I do not need.
So I created this project and I wanted to make the authorization process simple.
Using code:
Easy License is very simple to use, in order to verify a software, you need the following 3 steps.
1:create a public/private Key.
| 1234567891011121314151617 |
if(File.Exists("privateKey.xml") || File.Exists("publicKey.xml")) { varresult = MessageBox.Show("The key is existed, override it?", "Warning", MessageBoxButton.YesNo); if(result == MessageBoxResult.No) { return; } } varprivateKey = ""; varpublicKey = ""; LicenseGenerator.GenerateLicenseKey(outprivateKey, outpublicKey); File.WriteAllText("privateKey.xml", privateKey); File.WriteAllText("publicKey.xml", publicKey); MessageBox.Show("The Key is created, please backup it."); |
2:use Private key to create a license
| 1234567891011121314151617 |
if(!File.Exists("privateKey.xml")) { MessageBox.Show("Please create a license key first"); return; } varprivateKey = File.ReadAllText(@"privateKey.xml"); vargenerator = newLicenseGenerator(privateKey); vardictionary = newDictionary<string, string>(); // generate the license varlicense = generator.Generate("EasyLicense", Guid.NewGuid(), DateTime.UtcNow.AddYears(1), dictionary, LicenseType.Standard); txtLicense.Text = license; File.WriteAllText("license.lic", license); |
3:use Public key to validate the license
| 123456789101112131415161718192021 |
privatestaticvoidValidateLicense() { if(!File.Exists("publicKey.xml")) { MessageBox.Show("Please create a license key first"); return; } varpublicKey = File.ReadAllText(@"publicKey.xml"); varvalidator = newLicenseValidator(publicKey, @"license.lic"); try { validator.AssertValidLicense(); } catch(Exception ex) { Console.WriteLine(ex.Message); } |
Easylicense inside there is a tool called Licensetool , you can download the source code, run, see how it is created key, create Licens and verify license.
And the system also has a demo project that can help you.
Git, please help to add a star bar.
Https://github.com/EasyHelper/EasyLicense
Http://git.oschina.net/EasyHelper/EasyLicense
NET License tool, Easylicense!